Search
 
SCRIPT & CODE EXAMPLE
 

SQL

mssql get running queries by spid

declare
    @spid int
,   @stmt_start int
,   @stmt_end int
,   @sql_handle binary(20)

set @spid = XXX -- Fill this in

select  top 1
    @sql_handle = sql_handle
,   @stmt_start = case stmt_start when 0 then 0 else stmt_start / 2 end
,   @stmt_end = case stmt_end when -1 then -1 else stmt_end / 2 end
from    sys.sysprocesses
where   spid = @spid
order by ecid

SELECT
    SUBSTRING(  text,
            COALESCE(NULLIF(@stmt_start, 0), 1),
            CASE @stmt_end
                WHEN -1
                    THEN DATALENGTH(text)
                ELSE
                    (@stmt_end - @stmt_start)
                END
        )
FROM ::fn_get_sql(@sql_handle)
Comment

PREVIOUS NEXT
Code Example
Sql :: how to create a new db from dumb file mysql 
Sql :: Postgresql select join by date - Join rows where a timestamp value is equal to midnight of the date 
Sql :: how to get employee having maximum experience in mysql 
Sql :: sql select random procentage from rows 
Sql :: Character Limitation in sp_executesql sql server 
Sql :: Provera dupliranih konatakata 
Sql :: sql varchar(255) 
Sql :: how to set sql_mode for a query in CI model 
Sql :: show tables in oracle 
Sql :: sql server select query datatype 
Sql :: nuget sqllite-net-pcl 
Sql :: unpdate pl sql 
Sql :: Convert LDAP Epoch to Date 
Sql :: synapse sql table set pk 
Sql :: create darabase in sql 
Sql :: close sql query vb.net 
Sql :: oracle max field name length 
Sql :: get the next column of a table in mysql 
Sql :: psql check if sql script is valid 
Sql :: compound operator in sql 
Sql :: database db connection string format 
Sql :: $nbreLivres= mysqli_num_rows($result); $all = mysqli_fetch_all($result,MYSQLI_ASSOC); mysqli_free_result($result) mysqli_close($conn); 
Sql :: grouping function in mysql 
Sql :: How to take sum of column with same id in "JPQL?" 
Sql :: alter check command 
Sql :: oracle sql add column auto generated value 
Sql :: dump only data 
Sql :: mysql dump everythign 
Sql :: repeatable read trong sql server 
Sql :: create sql table 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =