tags:

views:

74

answers:

3

I want to insert value of primary key of a table to the foreign key in another table in SQL Server.

Please help me out..

+5  A: 
Insert Into FKTable (FKValue)
Select PKValue
From PKTable
Barry
A: 

AN EXAMPLE:

INSERT california_authors (au_id, au_lname, au_fname)
       SELECT au_id, au_lname, au_fname
         FROM authors
    WHERE State = 'CA'
Oyeme
A: 

SELECT PrimaryKey INTO NewTable FROM OldTable

Harold
Only works if NewTable doesn't exist...
JNK