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 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy