Click here to Skip to main content
15,879,844 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I am new to sql server and i have created a table named tour package with columns as shown below
id
heading
description
image

Here id is a primary key column and it has to be unique.Here i was unable to make the primary column identity column so that column will have unique id automatically as new records are added.Can anyone tell me how to insert unique values onto primary key column or tell me how to make primary key column identity column using sql query.Please help me.God bless you.Thank you in advance
Posted

I don't know what is the problem with setting the IDENTITY to your table. But alternatively, you can try inserting MAX(ID) + 1 in ID Column of your table. That'll be unique.

--Amy
 
Share this answer
 
Comments
faizel s 4-Aug-14 3:59am    
Thanks for trying to help me.i am unable to make primary key column identity column.Can u tell me how to make primary column identity column using sql query
_Amy 4-Aug-14 4:46am    
You'll have to drop the existing table(before dropping keep backup of data) then create the table with required structure. :)
You should be able to create a table with auto increment primary key, see, for instance: "Understanding Auto Increment in SQL Server"[^].
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900