Thursday
Sep012011

Import .trc files to database table

I've got a trace running at all times and it saves my traces into a number of .trc files, but how can I import the information into a table so I can get some value out of it?

Well first of all there's an awesome utility here (with whom I'm not affiliated in the slightest) called ClearTrace.

But sometimes I need more verbose reporting on my SQL traces, so I like to dump them into a table (e.g. "trace_table") and sort with my own queries.

Say you're at a place where you have a directory of .trc files on your server in C:\MyTraceFiles\.  Here's how you get them into your own table for easy manipulation:

 

 

Thursday
May052011

Update Table Based on Join to Different Database

Messed up an entire column of a large table today. Luckily it existed in another database on the same server. But how to get the data over? The syntax is tricky and I kept getting that the element "could not be bound". Here you go:
Wednesday
Aug182010

Fixing orphaned SQL user accounts

Ever refresh/restore a database only to find out your database logins don't match up with the database user accounts? I run the following query to simultaneously identify any database user permissions that aren't mapped to current database logins and also synch up the passwords to the appropriate logins. Copying/pasting the output to a new query window should get permissions back the way they should be (assuming you want to set the password to "opensezME!":
Wednesday
Aug182010

Get statement from sqlhandle

I reverse-engineered a script I found on MSDN to get the actual SQL statement/sproc from a SQL handle. Note that the sqlhandle identifier is not passed as a literal.