Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
DMarmolejos
Yak Posting Veteran
65 Posts |
Posted - 2008-07-25 : 12:03:00
|
| the table im using has a primary key already, but i dont want to use that. I would like to add a key that will just be a number for each rowany help is appreaciated, thanks |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2008-07-25 : 12:11:19
|
| so an IDENTITY column? what is your existing primary key?Em |
 |
|
|
DMarmolejos
Yak Posting Veteran
65 Posts |
Posted - 2008-07-25 : 12:13:41
|
| yes my existing PK is ItemCode which has rows missing in it compared to the ItemCodes in the other tables |
 |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2008-07-25 : 12:17:21
|
| look up IDENTIY in Books Online. as long as you don't have one already on your table you can just add a new column and make it an identity columnEm |
 |
|
|
DMarmolejos
Yak Posting Veteran
65 Posts |
Posted - 2008-07-25 : 12:23:12
|
| how would this key dynamically populate the # count of the rows listed in the table? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-25 : 14:01:13
|
quote: Originally posted by DMarmolejos how would this key dynamically populate the # count of the rows listed in the table?
When you make the column as identity, it will be automatically incremented by SQL Server for each insertion of row to table by the increment value you specify. you dont need to and you cant insert any explicit values to identity column unless you set identity insert on. |
 |
|
|
|
|
|