T-SQL

HOWTO: Run Singleton SELECT Queries in a Visual Basic Client

  • Article

This article demonstrates how to retrieve a single record from SQL Server by using the IRow interface with a singleton SELECT. The main purpose for this technique is to avoid the overhead of creating a recordset when you are fetching a single record. Because no recordset is actually created, only one read-only ADODB.Record is returned. This is true even if the specified SELECT results in multiple records being returned if a normal ADODB.Recordset is used.

2001-11-26

1,684 reads

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,141 reads

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,436 reads

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,656 reads

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,583 reads

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,073 reads

Blogs

Power BI Monthly Digest – October 2020

By

In this month’s Power BI Digest Matt and I will again guide you through...

Daily Coping 26 Oct 2020

By

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

Welcome to 3Cloud …

By

A little over a month ago, Pragmatic Works Consulting was a part of a...

Read the latest Blogs

Forums

Dividing data equally in 4 sessions

By S_Kumar_S

Hi All I have a table which contains the transactions done by cards. Below...

Unique value constraint among active records

By CanuckBuck

I have a lookup table that implements a system-generated Id for DRI purposes.  The...

Textfield comparator.

By ben.brugman

A client would like to be able to recognize similar free-texts in a text...

Visit the forum

Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers