Follow Savance Enterprise on FacebookFollow Savance Enterprise on LinkedinFollow Savance Enterprise on Twitter
Take Your Business to New Heights with Savance Enterprise

Savance Enterprise Support

Main

Knowledgebase: Administration
Find Details on a SQL Process
Posted by Jacob Fairbairn on 03 June 2014 09:35 PM

If you know the SPID of a process in OrderSavant (such as through the sp_lock or sp_who commands), you can run the following query to gain more information about that ID (the only thing that needs to be changed is the @spid variable at the top to whatever spid you want info on):

DECLARE @spid INT = 100
DECLARE @sqltext VARBINARY(128)
DECLARE @dbid INT

SELECT @sqltext = sql_handle, @dbid = dbid
FROM sys.sysprocesses
WHERE spid = @spid

SELECT spid AS 'SPID', text AS 'Query Text', client_net_address AS 'Client IP', program_name AS 'Client Type', p.dbid AS 'Database ID', DB_NAME(p.dbid) AS 'Database Name', hostname AS 'Database Server', status AS 'Procedure Status', connect_time AS 'Time Connected'
FROM sys.sysprocesses p
INNER JOIN sys.dm_exec_connections c
ON p.spid = c.session_id
INNER JOIN sys.dm_exec_sql_text(@sqltext) t
ON p.dbid = t.dbid
WHERE spid = @spid

This allows you to see what query was sent to the database, what the IP of the client is, what time it was sent, etc. The Client Type will help narrow down what client is being used (for example, ".Net SqlClient Data Provider" is the OrderSavant application/server, "Internet Information Services" is the OrderSavant webstore, etc).

 

If you would like to view all SPID's that are being blocked, you can also replace the last line with WHERE blocked = 0 instead.


Savance | The Company

At Savance, we set ourselves apart from our competition by keeping it personal. We actively request feedback, know our customers by first name, integrate their ideas into our product, and measure our success based on their happiness. The way businesses used to be run.

NAED American Lighting Association IMARK Plumbing STAFDA HARDI Blue Hawk HVACR Cooperative

Contact Us