SQL Server Compare Users Script

If you need to compare two users in SQL Server, here is a handy script. The output is simply a script to make the “UserToChange” sync up with the “ModelUser”. So this script generates a script.

SQL Jobs – Daylight Savings Risks

For those of us not lucky enough to live in Arizona (where daylight savings is ignored and clocks stay the same all year-round), we need to consider what time our SQL jobs are run. What happens with jobs that are scheduled for 2:30am when we spring the clocks ahead? They are skipped! What happens to… Read More »

SSMS Scripting Partition Scheme With Correct Filegroup

I almost found a bug… but it’s a feature after all. If you are scripting out a Partition Scheme in SSMS, you might notice that your script defaults to the PRIMARY filegroup. For the reason why, go here: http://connect.microsoft.com/SQLServer/feedback/details/641893/management-studio-incorrect-scripting-of-parition-scheme. To fix it, go into SSMS Tools, Options, SQL Server Object Explorer, Scripting, and under the… Read More »

Database File Space and Free Space

/* Author: Ben Farnsworth Date: 1/7/14 Get info on Data files */ IF OBJECT_ID(‘tempdb..#space’) IS NOT NULL DROP TABLE #space create table #space( name varchar(100) ,filename varchar(200) ,filesizeMB decimal(12,2) ,spaceusedMB decimal(12,2) ,freespaceMB decimal(12,2) ) exec sp_msforeachdb @command1 = ‘ use [?] INSERT INTO #space select name , filename , convert(decimal(12,2),round(a.size/128.000,2)) as FileSizeMB , convert(decimal(12,2),round(fileproperty(a.name,”SpaceUsed”)/128.000,2)) as… Read More »