Saturday, April 3, 2010

Create Temp table and temp varible table

-- Create Temp Table and insert single row
CREATE TABLE #TempTable (Col1 VARCHAR(100))
INSERT INTO #TempTable (Col1) VALUES('Temp Table - Outside Tran');
-- Create Table Variable and insert single row
DECLARE @TableVar TABLE(Col1 VARCHAR(100))
INSERT INTO @TableVar (Col1) VALUES('Table Var - Outside Tran');
-- Check the Values in tables
SELECT Col1 AS TempTable_BeforeTransaction FROM #TempTable;
SELECT Col1 AS TableVar_BeforeTransaction FROM @TableVar;

No comments:

Post a Comment