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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Unique ID in Temp Table

Status
Not open for further replies.

dibbo

Programmer
Nov 22, 2004
12
GB
I am performing a SELECT.... INTO #TempTable, which works fine. However, the rows aren't unique so i'm wanting to introduce a unique ID into the first column.

Is this possible, if so how?

TIA

Dave.
 
See IDENTITY function in BOL.
Code:
SELECT IDENTITY(int,1,1) AS RowID, ...
INTO #TempTable
FROM ...

--John [rainbow]
-----------------------------------
Behold! As a wild ass in the desert
go forth I to do my work.
--Gurnie Hallock (Dune)
 
Code:
SELECT *,newid()as [ID]
INTO #temp
from yourtable

[bandito] [blue]DBomrrsm[/blue] [bandito]
 
Just what I wanted.

Thanks.

Dave.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top