New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets matching tags of TSQL
SQL
Set NoCount ON
 
Declare @tableName varchar(200)
 
set @tableName=''
 
While exists
 
(
by Unknown (google)   April 16, 2010 @ 12:00pm
43 Views
no comments
 
SQL
DECLARE @RandomNumber float
DECLARE @RandomInteger int
DECLARE @MaxValue int
DECLARE @MinValue int
 
SET @MaxValue = 4
SET @MinValue = 2
 
SELECT @RandomNumber = RAND()
by Jerry Nixon   April 12, 2010 @ 9:37am
Tags: TSQL, Random
64 Views
no comments
 
SQL
-- Disable All constraint (FK)
EXECUTE sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT ALL"
GO
 
-- Enable
EXECUTE sp_msforeachtable "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT ALL"
GO
by Tareq Saleh   April 10, 2010 @ 1:33am
49 Views
no comments
 
SQL
set nocount on
 
use tempdb
 
if (object_id('x') is not null)
    drop table x
create table x (id int primary key identity(1, 1), date datetime, value bigint, total bigint)
declare @x table(id int, date datetime, value bigint, total bigint)
 
declare @d datetime
by Jerry Nixon   April 08, 2010 @ 4:19pm
99 Views
no comments
 
SQL
declare @x int, @y int, @z int
set @x = 1
set @y = 2
set @z = 1
 
-- returns @x (because not equal)
select case when @x = @y then null else @x end
 
-- returns null (because equal)
select case when @x = @z then null else @x end
by Jerry Nixon   March 05, 2010 @ 9:11am
87 Views
no comments
 
SQL
-- clean up any test artifacts
if object_id('test1') is not null drop table test1
if object_id('test2') is not null drop table test2
if object_id('test') is not null drop view test
GO
 
-- the partition column must have a CHECK 
-- and be part of the PRIMARY KEY
create table test1 (col1 int 
    primary key check (col1 = 1), col2 varchar(50))
by Jerry Nixon   March 05, 2010 @ 8:47am
75 Views
no comments
 
SQL
CREATE TABLE table1 (id int);
INSERT INTO table1 VALUES (1);
INSERT INTO table1 VALUES (2);
INSERT INTO table1 VALUES (3);
 
CREATE TABLE table2 (id int);
INSERT INTO table2 VALUES (2);
INSERT INTO table2 VALUES (3);
 
CREATE TABLE table3 (id int);
by Luciano Evaristo Guerche (Gorše)   January 13, 2010 @ 9:54am
97 Views
2 comments
 
SQL
SELECT SERVERPROPERTY('BuildClrVersion') AS [BuildClrVersion]
GO
SELECT SERVERPROPERTY('Collation') AS [Collation]
GO
SELECT SERVERPROPERTY('CollationID') AS [CollationID]
GO
SELECT SERVERPROPERTY('ComparisonStyle') AS [ComparisonStyle]
GO
SELECT SERVERPROPERTY('ComputerNamePhysicalNetBIOS') AS [ComputerNamePhysicalNetBIOS]
GO
188 Views
no comments
 
brought to you by:
West Wind Techologies


If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate