October 11, 2010 at 10:12 am
How do I set primary key to zero and add a new set of data to my table? Any suggestion will be appreciated.
October 11, 2010 at 10:16 am
Can you give more details about what you are trying to accomplish?
October 11, 2010 at 10:19 am
A primary key is the column(s) that uniquely identify each row. You don't set a PK to anything, you set the PK in each row to a unique value. That value is determined by the data, or it's a surrogate with something like NewID() or identity.
October 11, 2010 at 10:23 am
Are you talking about an identity column perhaps?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
October 11, 2010 at 10:28 am
I have some data currently in my table and I want to flush them and add a new set of data. So I thought setting the Primary key to zero will help. Any other suggestions will be be appreciated:-)
October 11, 2010 at 10:34 am
DELETE FROM <tablename>
or
TRUNCATE <TableName>
Both will remove all data from the table.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
October 11, 2010 at 10:41 am
If you have an identity column, DBCC CHECKIDENT will help you reseed the column. If you have other types of PKs, just add new data.
October 11, 2010 at 12:34 pm
Thanks guys. It worked. Appreciate it
Viewing 8 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply