www.google.co.in

Friday, February 20, 2009

MS SQL Troubleshooting

Sp_who & Sp_who 2





My friends! How to know your MS SQL, Doing what? , Way the system slow? , How may progress currently going on!. Here is the answer.

In SQL so many System stored procedures available. Let we see two stored procedures one is sp_who and sp_who2. This two are useful.


1.Sp_who (Show the Information about current users and processes)

Syntax :
---------
sp_who [[@login_name =] 'login']


Result:

Spid—The system process ID.
status—The status of the process (e.g., RUNNABLE, SLEEPING).
loginame—Login name of the user.
hostname—Machine name of the user.
blk—If the process is getting blocked, this value is the SPID of the blocking process.
dbname—Name of database the process is using.
Cmd—The command currently being executed (e.g., SELECT, INSERT)














2.Sp_who2

Show some additional information

Syntax :
---------
sp_who2 [[@login_name =] 'login']

Result:

CPUTime—Total CPU time the process has taken.
DiskIO—Total amount of disk reads for the process.
LastBatch—Last time a client called a procedure or executed a query.
ProgramName—Application that has initiated the connection (e.g., Visual Basic, MS SQL Query Analyzer)





---------------

No comments:

Post a Comment