we used integer primary key with auto increment in our database, instead of this if we would used guid, no need to take care of anything.
you can not transfer auto increment value because if transfer that value your primary key value changed in new database but doesn't change in your connected table.
so i found a new keyword out in mssql, we can use this keyword to used values stored in magic table means 'INSERTED','DELETED'
so i found a new keyword out in mssql, we can use this keyword to used values stored in magic table means 'INSERTED','DELETED'
update #customerOld set MerchantID = @NMerchantID
create table #customerPK (myNewPK INT,OldPK int,id int identity(1,1))
Insert into sai2.dbo.Customer
output INSERTED.CustomerID,0 INTO #customerPK
select MID,LoginID,Password,Pin,Email
from #customerOld As T
update #customerPK set OldPK = A.CustomerID from #customerPK AS T
inner join #customerOld AS A on A.ID = T.id
No comments:
Post a Comment