Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IDENTITY through SELECT

Status
Not open for further replies.

snyderj

MIS
Mar 2, 2001
242
US
What's a good way to create a sequential autonumber through a SQL Server view?

Specifically, can I do this through a SELECT ... INTO ... (perhaps using CAST?) or do I have to first CREATE TABLE with IDENTITY(1,1)?

(BTW, NEWID() creates a GUID that's too long for the customer.)

Thanks for any help you can offer.
 
Figured it out:

SELECT IDENTITY (int, 1, 1) AS [element name], [other elements]
INTO [destination table]
FROM [source table]

Only works for SELECT ... INTO.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top