Showing category "SQL Scripts" (Show all posts)

Constraints, Columns, and Tables oh My...

Posted by John Trumbul on Wednesday, October 10, 2012, In : SQL Scripts 
Over the years I have been guilty so many times of writing a rollback script that rolls column additions to a table. Which is essentially a script that will drop the added columns. When i create a new column with a default value i ALWAYS use a constraint name which i created. In the event you inherit someone else database who does not (not mine of course) :) forgetting to drop the default value constraint (which is something only an inexperienced DBA would do NOT ME of course) :)

As luck woul...
Continue reading ...

Quick but useful Index Fragmentation

Posted by John Trumbul on Friday, July 13, 2012, In : SQL Scripts 
Since I happen to be using this right now, I figure i would throw it up. Table not performing the way you would like? Perhaps the index is fragmented to high hell. Usinf this in combination with a Reorganize and Rebuild script should help a great deal.

SELECT ps.database_id, ps.OBJECT_ID,
FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) AS ps
AND ps.index_id = b.index...
Continue reading ...

This free website was made using Yola.

No HTML skills required. Build your website in minutes.

Go to and sign up today!

Make a free website with Yola