Top "Tsql" questions

T-SQL (Transact Structured Query Language) is the extension of SQL functionality supported by Sybase ASE and Microsoft SQL Server.

Syntax of for-loop in SQL Server

What is the syntax of a for loop in TSQL?

sql sql-server loops tsql syntax
Declare Variable for a Query String

I was wondering if there was a way to do this in MS SQL Server 2005: DECLARE @theDate varchar(60) SET @theDate = …

sql sql-server sql-server-2005 tsql dynamic-sql
SQL - The conversion of a varchar data type to a datetime data type resulted in an out-of-range value

I have been getting the following error when running a SQL to convert my data type value from varchar to …

sql-server tsql datetime
How to Join to first row

I'll use a concrete, but hypothetical, example. Each Order normally has only one line item: Orders: OrderGUID OrderNumber ========= ============ {FFB2...} STL-7442…

sql sql-server tsql sql-server-2000
I want to use CASE statement to update some records in sql server 2005

UPDATE dbo.TestStudents SET LASTNAME = ( CASE WHEN (LASTNAME = 'AAA') THEN 'BBB' WHEN (LASTNAME = 'CCC') THEN 'DDD' WHEN (LASTNAME = 'EEE') THEN …

sql sql-server tsql sql-update
Replace a newline in TSQL

I would like to replace (or remove) a newline character in a TSQL-string. Any Ideas? The obvious REPLACE(@string, CHAR(13), …

tsql newline
Simple way to transpose columns and rows in SQL?

How do I simply switch columns with rows in SQL? Is there any simple command to transpose? ie turn this …

sql sql-server tsql pivot
SQL MAX of multiple columns?

How do you return 1 value per row of the max of several columns: TableName [Number, Date1, Date2, Date3, Cost] I …

sql sql-server tsql
Script to kill all connections to a database (More than RESTRICTED_USER ROLLBACK)

I have a development database that re-deploy frequently from a Visual Studio Database project (via a TFS Auto Build). Sometimes …

sql sql-server tsql sql-server-2008 sql-server-2008-r2
How to check if a stored procedure exists before creating it

I have a SQL script that has to be run every time a client executes the "database management" functionality. The …

sql sql-server tsql stored-procedures