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,802 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

557 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

258 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

277 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

763 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

230 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

667 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

900 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

792 reads

Blogs

T-SQL Tuesday #176: That Piece of Technical Advice for the Past Me

By

DIVERSIFY! We devote a lot of time to mastering the technology that we are...

So You Want to Deploy Power BI Project files (PBIPs)?

By

Have you heard the news about the new Power BI Project files? Okay, maybe...

DBAs, Organizing Your SQL Scripts in Git

By

I wrote an article that was published on SQL Server Central on how to...

Read the latest Blogs

Forums

7 sept, scheduled book

By philip.scott

Comments posted to this topic are about the item 7 sept, scheduled book

7 sept, schedlued article

By philip.scott

Comments posted to this topic are about the item 7 sept, schedlued article

6 sept, published book

By philip.scott

Comments posted to this topic are about the item 6 sept, published book

Visit the forum

Question of the Day

Azure Data Lake Storage Gen 2

Azure Data Lake Storage Gen 2 is built on ...?

See possible answers