SP to import to a file

  • Script

Is a SP that imports a table to a file. You just put the table name, the path and the sa password and then you have it. It is important that it parse the table inserted (pubs.dbo.sales for example) and checks that the db, the table with the owner exists


1,663 reads

Encryption Example

  • Script

Here in this T-sql tip I'am trying to compare the word "Hijacker" with two cases(line 3 and 4). Now they are in same when you compare the case (letter to letter), now you change the case of word "Hijacker" in either of the lines and run this SQL statements it will return different results. This […]


658 reads

Granting Access Permissions...

  • Script

Usually when we recreate or rename a table we need to give the appropriate access permissions to the SQL users...this is very common in database under development environment where frequently table structure changes and we have to recreate it....we can accomplish this with Enterprise Manager but what will you do if Enterprise Manager fails to […]


806 reads

List all primary keys

  • Script

Thanks to Raul Sharma for his brilliant ideas. This is a modification of one of his scripts. The script takes only the user tables. Those tables which does not have PK are not listed!

4 (1)


720 reads

Pass an Array into a Stored Procedure

  • Script

Have you ever wished T-SQL allowed you to pass an array into a stored procedure? Well the spListToTable stored procedure listed below accepts a delimeted string and turns it into a table. Code your stored procedure to accept a varchar, create a temporary table, call spListToTable, and use the populated temporary table as if it […]

4.25 (4)


2,834 reads

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.


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)


9,144 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


1,437 reads


Daily Coping 20 Apr 2021


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

The Diverse Data Platform–Dativerse.io


The other day I got a note from Ben Weissman the other day that...

Extended Events and Azure SQL Database


Knowledge of how your system behaves is vital to better control, maintain, and grow...

Read the latest Blogs


Polybase and External table

By Rob Symonds

Hi - we have 2 SQL Server 2019 instances, both with Polybase installed. I...

Azure SQL Server Specs and Encryption

By EsquireDeveloper

Hello~ I administer a database application (Azure SQL Server Back End/MS Access Front End)...

How to get the sum of hrs. logged for today, past 1 week, this month, & quarter.

By marksquall

Dear SQLServerCentral members, Hello, and good day.  Hope all is well. May I asked...

Visit the forum


SQL Server Q&A from the SQLServerCentral community

Get answers