- Identity() "column" in SELECT INTO must have a name.
- variables are not allowed - even @ID + identity(int, 1, 1) won't work
SELECT INTO works only if target table doesn't exist, so you can try this:
Code:
DECLARE @ID AS INT
SET @ID = (SELECT MAX(@ID) FROM IDENTS)
SELECT firstname, identity(int, 1, 1) [b]AS some_name[/b] INTO newtable FROM oldtable
[b]UPDATE newtable SET some_name = some_name + @ID[/b]
Simple really, populate your table then add the same amount (your current max @ID value) to all IDs.
Just goes to show how thinking outside the problems domain helps, I was too concerned with getting the result within the identity(int, 1, 1) statement.
Spangeman, it won't be long before you realize that vongrunt not only thinks outside the box, he thinks outside of the outside of the box.
BTW, thanks for the kind words about my crosstab FAQ.
-Karl
[red] Cursors, triggers, user-defined functions and dynamic SQL are an axis of evil![/red]
[green]Life's uncertain...eat dessert first...www.deerfieldbakery.com[/green]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.