Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to create dynamic or tempary table in sql serv

Author  Topic 

mpolaiah
Starting Member

24 Posts

Posted - 2010-09-29 : 02:32:59
Hi all


How to create dynamic or tempary table in sql server 2005

Sachin.Nand

2937 Posts

Posted - 2010-09-29 : 02:42:34
www.sommarksog.se/dynamic_sql.html


PBUH

Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-09-29 : 04:33:51
If you only want to create a temp table then you can do either:

-- Table Variable : lasts only for the scope of the current batch and level (so procs you call can't access this)
DECLARE @tblVariable TABLE (
[Id] INT IDENTITY (1,1) PRIMARY KEY
, [someColumn] NVARCHAR(255)
)

-- Temp Table (local to batch but in this level and child levels (so can be referenced from a stored proc)
CREATE TABLE #tempTable (
[ID] INT IDENTITY (1,1)
, [someColumn] NVARCHAR(255)
)

There is lots of info online for both table variables and temp tables.

Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page
   

- Advertisement -