I am converting to an integer primary key and am having trouble seeding the new column data with a count of integer numbers.
Given an existing table:
create table t1 (
Id uniqueidentifier,
NewId int,
Data nvarchar(100)
)
How would I update existing rows with a count of numbers from 1 to the # of rows in the result set?
So:
|id |NewId |Data
-------------------------------
|ABC |null |first
|DEF |null |second
|GHI |null |third
Would become:
|id |NewId |Data
----------------------------
|ABC |1 |first
|DEF |2 |second
|GHI |3 |third
This is for a migration to using a hilo primary key with nhibernate, which is needed to reduce database round trips with between my application and database tiers, so IDENTITY is not an option for me.