Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Changing PK to transfer data to different database
Message
From
14/08/2002 13:59:56
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Changing PK to transfer data to different database
Miscellaneous
Thread ID:
00689669
Message ID:
00689669
Views:
54
Hello Group,

I am new and would like to change the Primary Key from one database to a acceptable Primary key in the database that I am moving it to.
The receiving database has a different range for acceptable PK's
The next primary key is stored in a table called snuniq and the Nextuniq (next Uniqe Primary Key Number) for the table I am creating is in the row where tblname = stusched


DECLARE @iNextuniq int

update snuniq
SET @iNextuniq = NextUniq
Where tblName = 'stusched'
Set @iNextuniq = @iNextUniq -1

If I have a table

cisPreStusched that has fields

suniq
meetuniq
coursec

and 2200 records

I have to delete the primary key scduniq from this table because there are 12
meetuniq,coursec combinations at the original and only three meetuninq,coursec
combinations at the recieving database.

I want to create a temporary table for the transfer called cisstusched
that has fields

scduniq ( a primary key that contains the value @iNextuniq + 1)
suniq
meetuniq
coursec



What would be the best wayto do this?

Thanks alot
Jim
Next
Reply
Map
View

Click here to load this message in the networking platform