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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 create identity field on a temporary table
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

esthera
Flowing Fount of Yak Knowledge

1410 Posts

Posted - 11/03/2013 :  10:13:03  Show Profile  Reply with Quote
how can I craeat an identity field on a temporary table

below didn't work

declare @t table ( RowNum int IDENTITY(1,1),code nvarchar(10),matchcount int,name nvarchar(50),laststatus nvarchar(10),city nvarchar(10),mydate datetime,imagefile nvarchar(50),ispaid bit)

James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 11/03/2013 :  10:29:33  Show Profile  Reply with Quote
quote:
Originally posted by esthera

how can I craeat an identity field on a temporary table

below didn't work

declare @t table ( RowNum int IDENTITY(1,1),code nvarchar(10),matchcount int,name nvarchar(50),laststatus nvarchar(10),city nvarchar(10),mydate datetime,imagefile nvarchar(50),ispaid bit)


The syntax is the table variable name followed by the keyword table, as in
declare @t table ( X int IDENTITY(1,1),code nvarchar(10),....


By the way, this is a TABLE VARIABLE rather than a temp table. A temp table is the one whose name starts with a # or ##. They can be used for similar purposes, but there are very significant differences between a table variable and a temp table.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 11/03/2013 :  14:27:23  Show Profile  Reply with Quote
quote:
Originally posted by esthera

how can I craeat an identity field on a temporary table

below didn't work

declare @t table ( RowNum int IDENTITY(1,1),code nvarchar(10),matchcount int,name nvarchar(50),laststatus nvarchar(10),city nvarchar(10),mydate datetime,imagefile nvarchar(50),ispaid bit)




cant find any obvious errors with sybtax. what was the error you got?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000