Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Changing PK to transfer data to different database
Message
De
14/08/2002 13:59:56
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Changing PK to transfer data to different database
Divers
Thread ID:
00689669
Message ID:
00689669
Vues:
53
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform