0

how to change id 290 and 291 to 1 and 2 in sql server , table - tbl_price

id       description quantity unitprice
290       abc          1        444
291       cde          3        333
krishna mohan
  • 905
  • 4
  • 20
  • 38
  • 2
    Why do you want to do that? Normally there should be no reason to update primary keys. – Tim Schmelter Jan 28 '16 at 08:45
  • actually i have deleted lot of records. and i just want to show two records as a sample and im using search option . retrieving records using id. select * from tbl_price where id between @@@ to @@@ – krishna mohan Jan 28 '16 at 08:47
  • @krishnamohan What do you mean by auto generate? is that an identity column? – Deep Kalra Jan 28 '16 at 08:56
  • @krishnamohan: i've provided the link to another (duplicate) question with the same topic. If your business logic relies on a range of values you should not (ab)use the identity column for this. Instead either add another column(f.e. `Sort` or a datetime column) or do it in the query itself. You can use `WITH CTE AS(SELECT RN=ROW_NUMBER()OVER(ORDER BY ID),* FROM T)SELECT * FROM CTE WHERE RN BETWEEN @x AND @y`. – Tim Schmelter Jan 28 '16 at 09:03

0 Answers0