From what little testing I have done, I don't thing you will be able to obtain the GUID from the table after an insert like with an auto incrementing or random integer column. With an integer you can use SELECT @ID = @@Idendity. But it doesn't appear to work with the GUID.
DROP TABLE tempdb..TestGUID
DROP TABLE tempdb..TestAutoID
GO
CREATE TABLE tempdb..TestGUID (
ID uniqueidentifier ROWGUIDCOL Not NULL DEFAULT (newid()),
TestValue varchar(50)
)
CREATE TABLE tempdb..TestAutoID (
ID int Identity (1, 1) Not Null,
TestValue varchar(50)
)
GO
INSERT INTO tempdb..TestGUID
( TestValue )
SELECT 'Test GUID'
SELECT @@Identity
INSERT INTO tempdb..TestAutoID
( TestValue )
SELECT 'Test Integer ID'
SELECT @@Identity
SELECT * FROM tempdb..TestGUID
SELECT * FROM tempdb..TestAutoID
OutPut
(1 row(s) affected)
NULL
(1 row(s) affected)
(1 row(s) affected)
1
(1 row(s) affected)
ID TestValue
E51F034D-BD69-4A34-9983-A2B1007FBA74 Test GUID
(1 row(s) affected)
ID TestValue
1 Test Integer ID
(1 row(s) affected)
As you can see the @@Identity returns a null for the GUID and the actual value for the integer ID. You may have to obtain the GUID value prior to the insert by placing it in a variable. Then you can use the variable in both the header and detail tables. Sorry I couldn't be much more help. Michael I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970)