The Multifunctioning DBA:

T-SQL

1

September 28, 2011  1:27 PM

Dynamic SQL



Posted by: Colin Smith
Dynamic SQL, T-SQL

The other day I wanted to write a query that would create my actual query in the results pane. I wanted to generate the sql to delete all the logins on the instance that met a certain criteria. Well I had some trouble but I worked it out and once I did I thought wow that was way easier than I was...

July 26, 2011  7:00 PM

T-SQL cursor to kill all spids connected by same program



Posted by: Colin Smith
T-SQL

I was recently asked by one of the application teams to come up with a way to kill all spids associated with a particular application once a day. Well I am not a t-sql guru by any means so I took this as a challenge and for once I did not pull out powershell but decided to go with T-SQL. With power...


June 22, 2011  11:00 PM

Check DB online before running Job



Posted by: Colin Smith
DB Online, T-SQL

I was also asked to make sure that I have jobs set up on my servers that have database mirroring set up. They only want the job to run if the database is online and they do not want to have to enable and disable jobs when failovers occur. So I did the following.


October 30, 2010  12:00 PM

Delete in Batch



Posted by: Colin Smith
T-SQL

Today I needed to delete 28 Million Rows from a table and I did not want to do it as one large statement because that would kill my log. Here is what I did. --Set your rows to deal with DECLARE @intloop int Select @intloop = count(*) from Table where Column < Something While @intloop...


September 16, 2009  4:37 PM

SQL Class



Posted by: Colin Smith
Education, SQL, T-SQL, Training

Found a nice article on some basic SQL. Check it out, it is never bad to have the knowledge even if you are not a DBA or SQL Developer. http://searchsqlserver.techtarget.com/tip/0,289483,sid87_gci1368296,00.html?track=sy41


1