Scripts

Technical Article

Full, diff and tlog backups based on recovery mode

    This a script which creates stored procedures that can be executed adhoc or set as sql agent jobs to check the recovery status and generate full, differential or transaction log backupf for each database if the database recovery status is set to full.  We have terabytes of data and set all production databases […]

You rated this post out of 5. Change rating

2003-06-06

925 reads

Technical Article

blocked  and blocker  spid and details

2 steps:step 1 => create   a table in master database called BlockCheckstep 2 =>  create the stored procedure in master  called  BLOCK_CHECK @database_name varchar(20)What SP  does:-    it gets the  spid that is blocked  + info about it (like what it does  at the moment  it is blocked)-    it gets the spid  that  acts as a […]

4 (1)

You rated this post out of 5. Change rating

2003-06-05

722 reads

Technical Article

Improving performance on joins to large tables.

In your tenure as a DBA/developer, you've probably been asked to write dozens of stored procedures similar to this:CREATE PROCEDURE ContactInfo@ContactID intASSELECT c.Name, a.Address, p.PhoneFROM Contact cLEFT JOIN ContactAddress aON c.ContactID = a.ContactIDLEFT JOIN ContactPhone pON c.ContactID = p.ContactIDWHERE c.ContactID = @ContactIDBut there is a more efficient way to write such a query.....particularly if you […]

4 (1)

You rated this post out of 5. Change rating

2003-06-03

1,410 reads

Technical Article

Find Duplicate Employees, Customers, Etc.

Customers, employees, etc. come and go.  They get entered multiple times in inconsistent formats in databases.This simple script finds the duplicates across multiple formats and is easily modified as needed.  It's so easy, my grandmother could do it. Oops! No offense Grandma.For very large databases, create and join two temp tables indexed on the namedatetring […]

You rated this post out of 5. Change rating

2003-05-30

205 reads

Technical Article

Show all User-Defined Datatypes for all Databases

This procedure displays all user-defined datatypes in all databases on a server.  Another example of the power of dynamic T-SQL, this procedure dynamically generates SELECT statements for the systypes tables in each database and UNIONs them together so that they display in one recordset.

You rated this post out of 5. Change rating

2003-05-30

152 reads

Blogs

A New Word: Querinous

By

querinous – adj. longing for a sense of certainty in a relationship; wishing there...

How to clear the SSMS cache?

By

How to clear the SSMS cache? If you are reading this,...

Master SQL Subqueries with This Free Course

By

Want to boost your SQL game? Check out this free course, SQL Subqueries: Real-World...

Read the latest Blogs

Forums

MDX SSAS Calculated measure for last totals + turnovers

By IvanMarkevich

I have a measure with totals for specific dates with the LastNonEmpty aggregation, and...

display bytea image

By Bruin

I moved a table from MsSql to Postgresql that had a field defined as...

When trying to use a LocalDB, I get an error

By Doctor Who 2

I tried to find an appropriate forum to post the question. This one seems...

Visit the forum

Question of the Day

SQL in an Azure VM Backup

If I use the Azure Backup service for automated backups of my SQL Servers in Azure VMs, how often can I configure log backups? (as of Dec 2024)

See possible answers