Rodney

Kill or Be Shamed

Published Wednesday, March 28, 2007 8:43 PM

Every tidbit of knowledge gleaned over years of working with a product comes at a price and that price is sometimes shame at not having known such slacious info beforehand. So it is with shame I admit that today I learned something I suspect I should have known. I run the risk of criticism of my peers who might send an electronic DUH my way, but for the neophytes of which we all are still in some way, I proffer the following:

When killing a SPID in SQL Server, especially one with an extensive rollback, one may type the following command to get an estimated time to completion for the rollback:

KILL (spid) WITH STATUSONLY

I learned this shamedly just a few weeks ago but it has served me well since, at least on two occasions. And further, it is not possible to kill an extended stored procedure. I can say this from today's experience trying to kill an xp_sendmail command to test a wayward SQL Mail configuration. BOL states also that one cannot kill one's own process.  I have to think about that one, buy you can check it out for yourself for the T-SQL KILL command in BOL. Ironically, when running kill with statusonly on a murdered SPID that is an extended stored procedure, the completion is 100% yet, the SPID will not disappear from Current Activity.

Speaking of Current Activity, Try:

sp_who2 active

Sure, everyone to my disgrace may know this, but again...for what it is worth to the few who2 may not.

And...Cntrl+0 will enter NULL values in fields in Enterprise Manager when opening a recordset from a table with OPEN.

And in a command prompt a command piped to CLIP (In Windows Server 2003) will send the results to the clipboard. Try:

DIR (pronounced DUH for my shame) | CLIP

And finally, the one most everyone knows but there is little documentation that I have found, in Query Analyzer, highlighting sections of a query and pressing Execute will only execute the highlighted code.

And finally, I will say that using a script project in SQl Server Management Studio is a nice way of organizing commonly used queries. If you have not tried to create a script project and consolidate your scripts, you should try it.

Time is out....LOST is airing now. Priorities, you know.  And speaking of priorites...

tomorrow.

by Rodney

Comments

 

WBrewer said:

Duh!

Actually, the CLIP feature sounds nice but it aint in Win 2000 or XP. Silly really, as it wouldn't take long to write. The 'Softies must be asleep at their desks, or too busy thinking up new devious technologies to baffle us with.

What I've always wanted to know (but have been too ashamed to ask) is how one flicks through the open query windows in SSMS. In good old Query Analyser, you just power through the windows at high speed with CNTL TAB, but in SSMS, you get a wretched hateful dialog box instead listing all the open windows (pretty meaningless names too, unless you've saved them). You can just about flick through by using CNTL SHIFT TAB in a sort of ripple, and ignore the dialog box, but it isn't the same. Is there a clever keystroke that allows you to flick through the open queries at high speed?
March 29, 2007 2:58 AM
 

Rodney said:

Actually, you can add clip.exe from Windows 2003 to XP and it will work on XP too. Don't know about W2K.
March 29, 2007 7:02 AM
 

Phil Factor said:

I seem to remember that CLIP.EXE was part of the Windows Resource Kit. It runs on everything and can be downloaded from all over the place.  I've sent William a copy.

I do the CNTL SHIFT TAB  ripple ripple too. Wish I knew a better keystroke
March 29, 2007 2:43 PM
 

sam said:

Readers should note, this STATUSONLY option gives progress of a rollback IN PROGRESS.  It will not estimate the time needed to rollback a currently executing batch.  That's what I read - since that is what I was hoping for :)
April 2, 2007 6:54 PM
 

Philip Kelley said:

The SSMS window-tabbing thing was driving me insane when, tracking down some other SQL Server 2005 bugaboo, I stumbled across the Micosoft SQL Server complaint--err, suggestion forum. I griped about whatever was irking me (the need to manually adjust the width of every.single.column in SQL Profiler's GUI *just to see the column names*), and while there I decided to gripe about SSMS windows too.

The thing is, they make it fairly easy to check if anyone else has had the same problems... and I found someone else had already griped. MS's response? Something lame like "sorry, we're using Visual Studio's interface, go ask them".

But, buried in the comments and feedback section, some unsung saint of a .net code-jockey had documented a workaround he'd worked out. I tried it on my box, it works, and now SSMS is just a little bit less irritating. (Now if only they'd give me back my ctrl+B...)

It was complex, if not eldritch, and I knew I'd never remember it--so I posted it on a forum over in SQLServerCentral.com, where I knew I could always find it. Such as tonight, when I read these posts. If this helps you as much as it helped me, pass it on in whatever form you find suitable!

  Philip

http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=146&messageid=356368
April 23, 2007 10:08 PM
 

Phil Factor said:

This really works! It also works for SSMS. There is an explanation of how to reconfigure your keyboard for Visual Studio at http://msdn2.microsoft.com/en-us/library/bb245788(vs.80).aspx (Visual Studio 2005 IDE Tips and Tricks) which explains the background to the workaround. Fascinating, and I wish I'd read it a long time ago.

Thanks a lot for the contribution, Philip! (and to ayeltsov for the workaround)
April 24, 2007 4:42 AM
You need to sign in to comment on this blog

















<March 2007>
SuMoTuWeThFrSa
25262728123
45678910
11121314151617
18192021222324
25262728293031
1234567
JSON and other data serialization languages
 The easiest way to speed up an Ajax application is to take out the 'X' and use JSON rather than XML. Of... Read more...

Embedding Help so it will be used
 It is not good enough to make assumptions about the way that users go about getting help when they use... Read more...

Linus Torvalds, Geek of the Week
 Linus Torvalds is remarkable, not only for being the technical genius who wrote Linux, but for then... Read more...

Using Exchange 2007 for Resource Booking
 The process of booking various resources to go with a meeting room just got a whole lot easier with... Read more...

Dynamically generating typed objects in .NET
 When you are binding Data to DataGrid in .NET, this has to be done at design-time. That's fine if you... Read more...