Format:
Recent snippets matching tags of TSQL
Set NoCount ON Declare @tableName varchar(200) set @tableName='' While exists (
43 Views
no comments
DECLARE @RandomNumber float DECLARE @RandomInteger int DECLARE @MaxValue int DECLARE @MinValue int SET @MaxValue = 4 SET @MinValue = 2 SELECT @RandomNumber = RAND()
64 Views
no comments
-- 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
49 Views
no comments
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
99 Views
no comments
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
87 Views
no comments
-- 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))
75 Views
no comments
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);
97 Views
2 comments
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
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
