Showing posts from February, 2011
This is actually quite simple. There is 'startup' option that you can set to the procedure. There are a few limitations though: - sp must reside in the [master] database - it's ow…
On some occasions we need to update an entry in a table in case there is an entry otherwise we need to insert that data into the table. The easiest way to do this is something like this IF EXISTS …
-- Script to check the orphan user EXEC sp_change_users_login ' Report ' --Use below code to fix the Orphan User issue DECLARE @username varchar (25) DECLARE fixusers CURSOR FOR …
This may provide some light on the usage of DBCC UPDATEUSAGE and sp_updatestats DBCC UPDATEUSAGE corrects the rows, used, reserved, and dpages columns of the sysindexes table for tables and clustered…
Excellent dmf that shows, for each file that SQL Server uses for the databases, stats on how frequently the file has been used by the database. This is one of the primary dynamic management views I u…
Aside from those integrated into SQL Server (e.g. xp_cmdshell) it's not often I come across the need to use Extended Stored Procedures but an application I installed recently required that I add …
There's a great little feature of SQL Server that allows you to execute command-line statements, allowing you to run batch files, get directory listings or call executables. The feature is acces…
During a recent consolidation exercise I was migrating one database at a time and then taking the old copy offline, unfortunately one of the DBs had (un-knowingly) been my default database and next t…