Knowledgy SQL Consulting LLC

Erwin Data ModelSome SQL Code that I've written that have helped me in the past:

Count Rows in a Flat File Table

cpColumnRowCounts

I used the procedure to count rows within the flat file table. Columns that had repeating groups or a very low distinct row count were columns that needed to be seperated into their own table. I like using cp, for custom procedure, to prefix my stored procedure names. This way they appear at the top of the list, before any system procedures and most other procedures, in SQL Studio Manager.

Automatically defrag indexes

sp_IndexDefrag

This procedure automates checking for index fragmentation and defrags when below a threshold parameter. Logical Scan Fragmentation and, to a lesser extent, Extent Scan Fragmentation values give the best indication of a table's fragmentation level. Both these values should be as close to zero as possible (although a value from 0% through 10% may be acceptable). It should be notedthat the Extent Scan Fragmentation value will be high if the index spans multiple files. I prefixed the procedure with sp_ because I wanted to be able to store it once in the Master database and be able to run it from any database.

Batch Grant Permissions

sp_GrantExec

This code will quickly grant execute rights to either an object or all objects for a particular user or all users in that database. I prefixed the procedure with sp_ because I wanted to be able to store it once in the Master database and be able to run it from any database.

Contact Knowledgy Today!

If you would like a copy of my current Resume or any information fill in this form. You will be contacted as soon as possible. Please fill in all required fields.
Thank You.