SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


usp_SQL_In_sp_who2


usp_SQL_In_sp_who2

Author
Message
Brandon Forest
Brandon Forest
Right there with Babe
Right there with Babe (749 reputation)Right there with Babe (749 reputation)Right there with Babe (749 reputation)Right there with Babe (749 reputation)Right there with Babe (749 reputation)Right there with Babe (749 reputation)Right there with Babe (749 reputation)Right there with Babe (749 reputation)

Group: General Forum Members
Points: 749 Visits: 446
Comments posted to this topic are about the item usp_SQL_In_sp_who2
lbabs
lbabs
SSC Rookie
SSC Rookie (32 reputation)SSC Rookie (32 reputation)SSC Rookie (32 reputation)SSC Rookie (32 reputation)SSC Rookie (32 reputation)SSC Rookie (32 reputation)SSC Rookie (32 reputation)SSC Rookie (32 reputation)

Group: General Forum Members
Points: 32 Visits: 152
Very cool. But it would be nice to get rig of the cursor and replace with Min/Max looping logic. Otherwise this is an excellent utility.
Alan Vogan
Alan Vogan
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1469 Visits: 585
Nice surf. 3 of us took a 2 hour brunch on Tuesday... :-D
mstjean
mstjean
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1513 Visits: 2556
You don't indicate what version you're running, but if SQL2005 you could (quick n dirty) do this.. it returns a superset of the columns you used but you can always customize that.

SELECT
sp.*,
DB_NAME(sp.dbid) dbname,
OBJECT_NAME(st.objectid,sp.dbid) as oname,
CAST(st.text AS VARCHAR(7000)) as script
FROM
sys.sysprocesses sp
CROSS APPLY
sys.dm_exec_sql_text (sp.sql_handle) st

...BOL mentions sys.sysprocesses is not long for this world so you *really* should use one of these-- depending on what you need:

sys.dm_exec_connections
sys.dm_exec_sessions
sys.dm_exec_requests


Cursors are useful if you don't know SQL
aussierock
aussierock
Grasshopper
Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)

Group: General Forum Members
Points: 21 Visits: 108
Nice Wave Man! memories of Kirra Point.
doc_sewell
doc_sewell
SSC-Addicted
SSC-Addicted (425 reputation)SSC-Addicted (425 reputation)SSC-Addicted (425 reputation)SSC-Addicted (425 reputation)SSC-Addicted (425 reputation)SSC-Addicted (425 reputation)SSC-Addicted (425 reputation)SSC-Addicted (425 reputation)

Group: General Forum Members
Points: 425 Visits: 123
I have problems with getting it to run. I am getting errors on the single quotes (Unicode probably). Is there an easy way to fix it?
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum







































































































































































SQLServerCentral


Search