March 16, 2011 at 12:29 am
I have a table called 'Recent_Upload' that contains 52 fields. I want to copy that table to a new table and add a unique key to it. Can this be done by executing one query? What would a query like that look like?
Thank you! 🙂
March 16, 2011 at 12:34 am
How about this?
SELECT IDENTITY(INT, 1, 1 ) AS ID , Col1 , Col2 ......Col52
INTO New_Table
FROM Old_Table
CREATE UNIQUE NONCLUSTERED INDEX IDX_New_Table_ID
ON New_Table(ID)
March 16, 2011 at 12:40 am
At first glance I can understand generally everything except 'IDENTITY(INT 1, 1)'. What is that doing exactly?
March 16, 2011 at 12:46 am
Thats a function much like your normal IDENTITY property of a column.
You can refer and learn more about that function HERE
I'am sorry , i am actually in the middle of completing a work, so cant explain in detail abt the function. When done with the task, i ll come back to explain 🙂
March 16, 2011 at 1:09 am
I read the documentation and it's very clear. Thank you very kindly for this wonderful post.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply