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,152 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,665 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,613 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

9,180 reads

Blogs

Daily Coping 19 Aug 2022

By

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

Daily Coping 18 Aug 2022

By

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

New parameter in sp_DBPermissions and sp_SrvPermissions: @CopyTo

By

I’ve added a new parameter to my permissions scripts (well, just the main two...

Read the latest Blogs

Forums

ssrs calculation not working

By jeannier175

I have a SSRS report that i need to calculate the Variance percent totals...

A sample of DML trigger to help you under how trigger working

By Vincent92

Comments posted to this topic are about the item A sample of DML trigger...

Azure SQL Server - consideration

By veerablog

There are a few options for Azure SQL Server Vanilla Azure SQL Server (SaaS)...

Visit the forum

Ask SSC Logo Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers