T-SQL

Technical Article

Loop through records without using a cursor

  • Script

I sometimes have to loop through records in a database and perform a specific action on the value that is returned. For example, In the script below I loop through the user tables in sysobjects and simply print them out. This technique is useful when dropping all indices/triggers on a particular table, or adding WITH […]

3 (2)

2001-11-25

9,149 reads

Technical Article

Update Foreign Key References

  • Script

This script updates all foreign key references for the specified table. Useful if you need to delete a row. The follow example would update all uses of TableA.IDENTITYCOL where the value is 1 to the value of 2. Example usage: EXEC usp_updateFK 'TableA', 1, 2

2001-11-03

1,438 reads

Technical Article

Optimize Character Field Usage

  • Script

This stored procedure was designed to scan all your character based columns in a particular database and show the minimum, maximum and average data length. As well as give an efficiency rating of the data stored. Input: None Output: Table name, Column name, Defined datatype and length, Average length of data for that column, Minimum […]

2001-08-10

1,663 reads

Technical Article

Generate Insert Statements Easily

  • Script

This script will generate insert statements for the given tables. You can pass the tables names, separated by commas, into sp_DataAsInsCommand stored procedure as in the example below: EXEC sp_DataAsInsCommand 'employee,titleauthor,pub_info' Updated on 5/25/01 to correct an issue with columns that are short like a column defined as char(1), to correct another issue with the […]

3 (9)

2001-08-09

4,605 reads

SQLServerCentral Article

ANSI Joins

  • Article

Are you confused by all this inner join style syntax that is becoming more and more prominent lately? This article by Neil Boyle will help you find your footing in the ANSI join syntax.

5 (3)

2001-05-29

8,732 reads

Blogs

Checking if a database has a master key–#SQLNewBlogger

By

Another post for me that is simple and hopefully serves as an example for...

Join me in Germany in June

By

I have been selected to speak at the DataGrillen conference later this year. I will be...

Daily Coping 26 Jan 2022

By

I started to add a daily coping tip to the SQLServerCentral newsletter and to...

Read the latest Blogs

Forums

Restore autmomation

By ramyours2003

i need to  create sql job  which perform automate restore of the databases  with...

Stored Procedure error log integration with APM tools

By stevetb

Hi all, We typically consolidate our logging in an APM tool (eg: like Datadog)....

Cohort Cumulative Rates in SQL

By eugeniexxx

I have a question regarding a problem for cohort analysis in SQL (any dialect)....

Visit the forum

Ask SSC Logo Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers