Neil Jacobson


Technical Article

Build a script for CREATE DATABASE/FOR ATTACH

It is easy enough to detach and reattach databases in SQL 2000 providing you have less than 16 files to attach.I manage some very large databases and these sometimes need to be detached and reattached (i.e. for moving a database file from one volume to another).I have more than 16 files to contend with on […]

4.67 (3)

You rated this post out of 5. Change rating

2003-01-22

2,857 reads

Technical Article

Build Restore Scripts for All User Databases

Something I really hate is typing something repetitive.  To prepare for our Disaster Recovery plan, I wrote this script.It is a bit strange in that it requires 2 run iterations to generate the desired result.I use a naming standard for backup files of the form:D_DBName.Bakand a naming standard for database files of the form:DBName_Dx.Mdf for […]

You rated this post out of 5. Change rating

2003-01-22

577 reads

Technical Article

Generate script to tidy up DB Logical File Names

You may be a tidy person who likes to keep naming standards for everything in SQL Server.  It is a good practice since it makes generating scripts for everyday DBA tasks a lot simpler.  I make all database files follow the following standard:DBName_D1.mdf     for primary filegroup dataDBName_I1.ndf     for index filegroupDBName_L1.ldf     for transaction […]

You rated this post out of 5. Change rating

2003-01-22

273 reads

Technical Article

SP to determine database file growth at intervals

I wrote this SP to be run from a job every night. Change the myDB reference to be a database on your system for DBA use.I just set up a job to run:Exec sp_CatchFileChangesThen I run in another step:Select * from mydb.dbo.tbl_sysaltfiles_3and output to a log file.Alternatively you could insert into another table with a […]

You rated this post out of 5. Change rating

2003-01-13

287 reads

Technical Article

Calculate Earth global distances

I wrote this sp to be able to calculate the distance between two locations on the earth if the latitude and longitude is known for each.  Could be useful for GPS work or maps.Usage:If I know the following city locations:Sydney         151.2 E             33.87 SCanberra       149.15 E             […]

5 (1)

You rated this post out of 5. Change rating

2003-01-09

775 reads

Technical Article

Check if batch is running.

WARNING:  This is resource intensive. Don't use except as a last resort.I wrote this to be able to find if a TSQL batch is running already on a SQL Server.  I use this rarely when I have to know to prevent running something twice.Usage:DECLARE @RC intDECLARE @SQLBatch nvarchar(255)-- Set parameter valuesEXEC @RC = [master].[dbo].[sp_RunningCheck] @SQLBatch […]

You rated this post out of 5. Change rating

2003-01-09

386 reads

Technical Article

Convert Degrees Minutes Seconds to Decimal UDF

I wrote this function to work with my sp_EarthDistance stored procedure.It converts the regular degrees/minutes/seconds representation of angles to a decimal number.Remember to use '' instead of ' within a string to be treated a character and not an end quote.Sydney location    151¦12'0 "E               33¦52'0 "S and in […]

4 (1)

You rated this post out of 5. Change rating

2003-01-09

805 reads

Technical Article

Proc to script a user role and object permissions

I wanted to be able to prepare a script of User Roles and permissions for objects in a database so I can be prepared for backup and disaster recovery scenarios. I also wanted to be able to audit the permissions for each role.I wrote this stored procedure to do this.  The usage is:Use NorthwindgoDECLARE @RC […]

You rated this post out of 5. Change rating

2002-10-09

923 reads

Technical Article

Check for orphaned user or sid in syslogins

When rebuilding a server or setting up a backup or DR server the logins need to be added into master and synchronised with the user databases.Inevitably there are orphaned users is sysusers or the sid's do not match with syslogins.I use this stored procedure to check for a particular user when the user experiences a […]

You rated this post out of 5. Change rating

2002-03-07

809 reads

Blogs

T-SQL Tuesday #180: Good enough is perfect Roundup

By

This month, I prompted bloggers to discuss whether good enough is perfect. Thank you to all...

Using SQL Compare with Read-only Access

By

Recently a customer asked if SQL Compare and SQL Data Compare can be used...

Off to Live 360

By

I am off to Live 360 today, on my last trip of the year....

Read the latest Blogs

Forums

Immediate Recap: Pounds 124, Clippers 117

By Emanis

No person would create the situation that a eye-catching video game of basketball was...

NFC Wild Card Breakdown: Cowboys vs. Packers

By Emanis

The Fresh Orleans Saints are shed the playoffs for the 3rd instantly time, which...

how can i tell if our db2 driver is ms or ibm or other?

By stan

i see this in the definition of a linked server on our wh sql...

Visit the forum

Question of the Day

A Strange Result

What does this code return in SSMS 20 from SQL Server 2019?

select '|' + CHAR(0)+'abc' + '|';

See possible answers