CodePaste Logo
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
 
ALTER PROCEDURE [dbo].[pr_OrderItem_history] (
@PipCode    varchar(50),
@BarCode    varchar(150),
@Status     Char(10)
)
AS
BEGIN
select 
PID.PO_ItemID,
by Guru   September 24, 2011 @ 2:25am
Tags: CASE, Select, tsql
53 Views
no comments
 
SQL
-----------------------------------------------------------
-----------------------------------------------------------
--- BASIC DATA BASE 
create database Producction
go
use [Producction]
create table Categorias 
(
    Id int identity (1,1)not null
    ,Nombre varchar (100)
by racsonp   September 05, 2011 @ 9:40pm
Tags: sql, TSQL
50 Views
no comments
 
SQL
-----------------------------------------------------------
-----------------------------------------------------------
-- SQL Ccommand's help
select getdate()
select GETUTCDATE ()
set dateformat mdy
select  convert(varchar, Fecha, 106) ,convert(varchar, Fecha, 103) 
 
---Kill tables
by Oscar   September 05, 2011 @ 9:36pm
Tags: sql, TSQL
51 Views
no comments
 
SQL
create function dbo.fn_SpacePascal(@in varchar(500)) RETURNS varchar(500)
begin
 
/*
      by: jerry
      on: 5/2011
      to: seperate PascalCaseWords to Pascal Case Words
*/
 
      if (@in COLLATE Latin1_General_CS_AS = UPPER(@in)) 
by Jerry Nixon   July 19, 2011 @ 5:47pm
Tags: TSQL
134 Views
no comments
 
SQL
CREATE FUNCTION [dbo].[udf_StringToTable]
(
    @string VARCHAR(MAX),
    @delimiter CHAR(1)
)
RETURNS @output TABLE(
    data VARCHAR(256)
)
BEGIN
by jaredmroberts   May 31, 2011 @ 11:01am
89 Views
no comments
 
SQL
create function dbo.fn_SpacePascal(@in varchar(500)) RETURNS varchar(500)
begin
 
/*
    by: jerry
    on: 5/2011
    to: seperate PsacalCaseWords to Pascal Case Words
*/
 
    if (@in COLLATE Latin1_General_CS_AS = UPPER(@in)) 
by Jerry Nixon   May 05, 2011 @ 2:31pm
Tags: SQL, TSQL, FUNCTION
146 Views
no comments
 
SQL
CREATE FUNCTION [dbo].[udf_DatesInRange] 
(    
    -- Add the parameters for the function here
    @StartDateTime DateTime,
    @EndDateTime DateTime
)
RETURNS @Dates TABLE
(
    DateInRange DateTime
)
by jaredmroberts   May 03, 2011 @ 11:06am
Tags: TSQL
98 Views
no comments
 
SQL
Set NoCount ON
 
Declare @tableName varchar(200)
 
set @tableName=''
 
While exists
 
(
by Unknown (google)   April 16, 2010 @ 12:00pm
243 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
370 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
284 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
400 Views
1 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
591 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
353 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
289 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
440 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