Display Row Number
-
I am trying to reset the PK on a SQL Server table. The key is auto populated and automatically increments by 1. I have cleared all the data and want to repopulate. Is there a way to have the first Id be equal to 1? Currently numbering starts where the last data ended. Second question is there a way to print the row number in a select statement? Jason W.
-
I am trying to reset the PK on a SQL Server table. The key is auto populated and automatically increments by 1. I have cleared all the data and want to repopulate. Is there a way to have the first Id be equal to 1? Currently numbering starts where the last data ended. Second question is there a way to print the row number in a select statement? Jason W.
If I remember correctly, to reset the row number field you need to TRUNCATE TABLE. Michael "I've died for a living in the movies and tv. But the hardest thing I'll ever do is watch my leading ladies, Kiss some other guy while I'm bandaging my knee." -- The Unknown Stuntman
-
If I remember correctly, to reset the row number field you need to TRUNCATE TABLE. Michael "I've died for a living in the movies and tv. But the hardest thing I'll ever do is watch my leading ladies, Kiss some other guy while I'm bandaging my knee." -- The Unknown Stuntman
Exactly what I was looking for thanks. :) Jason W.
-
I am trying to reset the PK on a SQL Server table. The key is auto populated and automatically increments by 1. I have cleared all the data and want to repopulate. Is there a way to have the first Id be equal to 1? Currently numbering starts where the last data ended. Second question is there a way to print the row number in a select statement? Jason W.
-
I am trying to reset the PK on a SQL Server table. The key is auto populated and automatically increments by 1. I have cleared all the data and want to repopulate. Is there a way to have the first Id be equal to 1? Currently numbering starts where the last data ended. Second question is there a way to print the row number in a select statement? Jason W.
The only mode that I know, is removing the PK state, repopulating the fileld and setting like PK again... Carlos Antollini. Sonork ID 100.10529 cantollini
-
I am trying to reset the PK on a SQL Server table. The key is auto populated and automatically increments by 1. I have cleared all the data and want to repopulate. Is there a way to have the first Id be equal to 1? Currently numbering starts where the last data ended. Second question is there a way to print the row number in a select statement? Jason W.
To reseed your identity column you can use the following dbcc command. Not too sure if it's supported though:
dbcc checkident ( <tablename>, RESEED, <newvalue> )
example:dbcc checkident(authors, RESEED, 100000)
-
To reseed your identity column you can use the following dbcc command. Not too sure if it's supported though:
dbcc checkident ( <tablename>, RESEED, <newvalue> )
example:dbcc checkident(authors, RESEED, 100000)
Oh, and for ther row number you might want to check out this link: http://www.sqlteam.com/item.asp?ItemID=1491