February 21, 2006 at 4:12 pm
Hi,
Is there a way to automatically create an identity field on SELECT for sequential number?
Rather than creating a temporary table with an identity field than insert the values from the SELECT query, then returning this temp table instead?
Thanks in advance.
February 21, 2006 at 6:12 pm
You can, but only in conjunction with the SELECT INTO statement, e.g.
SELECT IDENTITY(int, 1,1) AS ID_Num
INTO NewTable
FROM OldTable
See BOL for more info.
February 22, 2006 at 7:02 am
If the table has a unique key then
SELECT (SELECT COUNT(*) FROM
b WHERE b. <= a.), a.
FROM
a
but check the performance though
Far away is close at hand in the images of elsewhere.
Anon.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply