Scripts

Technical Article

Truncating and deleting all tables in a database

Sometimes, during test stage, you may need to truncate or delete all your tables in a database, without droping constraints, truncating and recreating constraints (DRI). You can use the TRUNCATE TABLE statement to removes all rows from a table without logging the individual row deletes, but tables referenced by a FOREIGN KEY constraint can not […]

★ ★ ★ ★ ★ ★ ★ ★ ★ ★

(3)

You rated this post out of 5. Change rating

2002-04-17

1,605 reads

Technical Article

Copying Data from one Database to Another

This script will be helpful to only those people who arehaving identical database with different names.This script can be used to copy single or multiple tables from one database to anotherThe parameters @tname , source database and target database are important for the script to work. In the script below I have considered two databases […]

★ ★ ★ ★ ★ ★ ★ ★ ★ ★

(1)

You rated this post out of 5. Change rating

2002-04-16

1,626 reads

Technical Article

Get users permissions with mapping thru role.

This procedure is similar to sp_helpprotect except to extends a bit on the concept with roles involved. If for instance a user has right on a TableX but they are not mapped directly to the user but instead to a role then sp_helpprotect does not tell you this. This will tell you how the user […]

★ ★ ★ ★ ★ ★ ★ ★ ★ ★

You rated this post out of 5. Change rating

2002-04-16

1,736 reads

Technical Article

List of triggers in a database

Give the following information, about triggers in the database.Parent_Name      Parent_Type Name                         Type               Insert Update Delete IsFirstInsertTrigger IsFirstUpdateTrigger IsFirstDeleteTrigger IsLastInsertTrigger IsLastUpdateTrigger IsLastDeleteTrigger

★ ★ ★ ★ ★ ★ ★ ★ ★ ★

(2)

You rated this post out of 5. Change rating

2002-04-16

867 reads

Technical Article

Preventing accidental overwrites with update SPs

Say you wanted to create an SP for updating records in a database.  How would you do this in such a way as to allow your users to edit only a subset of fields in the record, without overwriting the other fields, and without requiring verbose IF blocks and CASE statements in your code?Simple.  Use […]

★ ★ ★ ★ ★ ★ ★ ★ ★ ★

You rated this post out of 5. Change rating

2002-04-16

240 reads

Technical Article

Converting money to the word value.

With this script you can supply an money value such as $12525.83 and it will return the word value "Twelve Thousand Five Hundred And Twenty-Five Dollars And Eighty-Three Cents".It is comprised of a table for Number to Name and a procedure to parse into it's piecesNOTE: This only goes to billions at this point, but […]

★ ★ ★ ★ ★ ★ ★ ★ ★ ★

You rated this post out of 5. Change rating

2002-04-11

450 reads

Technical Article

How to get last restore date and orginal DBName.

This script will output the Orignal DB Name, Destination DB Name and Last Restore date for the databases. You get a specific database just add a where clause against the appropriate field. It makes use of the restorehistory and backupset tables in the MSDB database.

★ ★ ★ ★ ★ ★ ★ ★ ★ ★

(6)

You rated this post out of 5. Change rating

2002-04-11

2,599 reads

Blogs

T-SQL Tuesday #203: Risk and Reward

By

This is timely, as I’m currently on a boat in the Adriatic taking a...

dataMinds Connect 2026 – Slides & Scripts

By

You can find the slides and SQL scripts for my session “Spice up your...

How to Clear the SSMS Cache (SSMS 21 and Later)

By

How to Clear the SSMS Cache (SSMS 21 and Later) Updated...

Read the latest Blogs

Forums

Anyone knows where to download SQLexpress edition for 2022

By sqlfriend

Where to download earlier version of SQL server express 2022?   Thanks

Risk Vs Reward, The never ending ROI discussion.

By Pat Wright

Comments posted to this topic are about the item Risk Vs Reward, The never...

SSL/TLS Cert Validity Periods Decreasing

By Phil Parkin

Hi, to all of you who are using CA certs on SQL Server boxes...

Visit the forum

Question of the Day

Checking the Error Log III

If I want to run sp_readerrorlog on SQL Server 2025, what permissions do I need?

See possible answers