General information
Forum:
Microsoft SQL Server
Title:
Changing PK to transfer data to different database
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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only