Scripts

Technical Article

Auto Fix Orphaned Users

Add this procedure to the master database, it can then be executed from any DB to fix orphaned users (very useful when moving back to development). Using sp_msforeachdb with the proc allows you to resolve orphaned users in all databases in a single command: SP_MSFOREACHDB "USE ?; EXEC SP_AUTOFIX_USERS;"

★ ★ ★ ★ ★ ★ ★ ★ ★ ★

You rated this post out of 5. Change rating

2004-12-15 (first published: )

2,943 reads

Technical Article

Build DATELOOKUP table

This script creates a table named DATELOOKUP which is used for looking up date related values. Each record represents date related info about the date in the column dtDate. For example the iMonth column stores the integer value of the month of dtDate and sShortMonth stores the abbreviated name of that same month. Use this […]

★ ★ ★ ★ ★ ★ ★ ★ ★ ★

(1)

You rated this post out of 5. Change rating

2004-12-13 (first published: )

238 reads

Technical Article

Where_Am_I

This SP takes a string to be searched as input parameter, loops through all tables, views, Sp-s in the database andreturns the name of the object it was found and number of occurences

★ ★ ★ ★ ★ ★ ★ ★ ★ ★

(1)

You rated this post out of 5. Change rating

2004-12-10 (first published: )

697 reads

Technical Article

Finding first/last day of month by a date

This script finds the first day of previous, current and next month as well as last day of previous, current and next month.The calculation is based on the ISO date format which makes it independant of the date format used on the SQL Server.The calculation is performed from a date - it can be altered […]

★ ★ ★ ★ ★ ★ ★ ★ ★ ★

You rated this post out of 5. Change rating

2004-12-02 (first published: )

284 reads

Blogs

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...

The flight recorder: Replaying what an AI agent did on my SQL Server

By

“What exactly did it do on my server?” is the first question a DBA...

Read the latest Blogs

Forums

Alamat BCA KCP Thamrin Nine Telp:0821°7555°651

By layanan_Bca88

Telp/Wa 628217555651 Thamrin Nine Podium Area - UG Unit A, Jl. MH Thamrin No.10,...

Alamat BCA KCP Samanhudi Telp:08218200203

By R4nt4u

Telp/Wa 628218200203 Jl. Samanhudi No.57 B, RT.5/RW.3, Ps. Baru, Kecamatan Sawah Besar, Kota Jakarta...

Alamat BCA KCP AM Sangaji Telp:08218200233

By m4rt1n4

Telp/Wa 628218200233 Jl. A.M Sangaji No.020 A, RT.3/RW.04, Petojo Utara, Kecamatan Gambir, Kota Jakarta...

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