Scripts

Calculating Easter in SQL

Several months ago someone commented on a calendar thread that you should not even try to calculate Easter in SQL Server because the math was too hard.  That got me to thinking and I decided to see if that was actually the case. I found that there are several well known algorithms available - but […]

2020-04-06 (first published: )

672 reads

Select Group Members from Logins

Know who all the individual group members are for a given WINDOWS_GROUP login. This script uses the sys.xp_logininfo procedure to find group members for each login on an instance. This is useful when attempting to remove orphaned WINDOWS_LOGINS. May have issues working across your logged in domain.

2020-03-23 (first published: )

517 reads

Orphaned Users Search and Destroy

This script will find all orphaned users on all databases on an instance, and generate a script to drop each user. Simply execute, copy the values from the DropScript column to a new SSMS window and execute. There are two risks with this script. Use with caution: This script attempts to take into account users […]

2020-03-16 (first published: )

559 reads

String Search

The script searches through every column of every record in a database to find a value. It works with numbers too. Simply assign a value to @MyString. Indicate what datatype(s) you wish to search through, and indicate if you want wildcards, and execute. The search is smart and will only search through columns where @MyString is […]

3 (2)

2020-03-05 (first published: )

672 reads

Fiscal/Retail 4-5-4 Calendar Function

This function returns a 3 year calendar based on a 4-5-4/5-4-4/4-4-5 calendar, also known as a 52/53 week calendar.  The basis of this calendar function was derived from the NRF retail calendar published at https://nrf.com/resources/4-5-4-calendar and the Wikipedia article published at https://en.wikipedia.org/wiki/4%E2%80%934%E2%80%935_calendar. The calendar function requires 2 helper functions.  The helper functions were derived from […]

2020-02-19

132 reads

Amazon RDS SQL Server - Drop Database with Mirroring

Dropping database in RDS follows different method than dropping the database in local SQL Server. Below is the command to DROP the database in Amazon RDS EXECUTE msdb.dbo.rds_drop_database N'demodb' GO However when the SQL Server is configured with Multi-zone mirroring, then you need to set the partner to OFF and drop all active connections and […]

5 (1)

2020-01-17

163 reads

Blogs

Creating a New Sequence–#SQLNewBlogger

By

I wrote about sequences in an editorial recently and decided to start using them....

An All Star Lineup for EightKB

By

An online conference is coming on June 17, 2020 that is full of high...

How should I store currency values in SQL Server?

By

On Twitter, Michael Dyrynda writes: ?? Never ever ever ever ever ever ever ever...

Read the latest Blogs

Forums

Explanation of Page Splits

By stevec883

Q1 -- I have read quite a few articles on page splits and am...

(duplicate)

By stevec883

(sorry, this was a duplicate)

Script error

By sizal0234

I am trying to monitor the sql services on couple of instances and found...

Visit the forum

Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers