Hi,All
How to insert different records into multiple sql tables with same uniqueidentifier in sql server.
thanx
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Roei BarRank #1,271 · 1.4K reputationPosted Aug 29, 2009, 12:21 AM EDT
declare @myKey uniqueidentifier
select
@myKey = newId()
and than do the insert to your Tables with the @myKey Indicator
if you liked this dont forget to mark it as "Accepted Answer"
roy himanshu98 reputationPosted Aug 29, 2009, 12:54 AM EDT
thanks for ur response,but still iam not getting output.plz give the syntax clearly.plz
Roei BarRank #1,271 · 1.4K reputationPosted Aug 29, 2009, 8:19 AM EDT
select
@myKey = newId()
insert into TableA (id,Name)
values(@myKey,'roy')
insert into TableB (id,Name)
values(@myKey,'roy')
roy himanshu98 reputationPosted Aug 30, 2009, 9:33 PM EDT
declare @myKey uniqueidentifier
select
@myKey = newId()
insert into persons (id,lastname,firstname)
values(@myKey,'hai','world')
insert into persons1(id,c1,c2)
values(@myKey,'hello','roy')
hi,this is my code.but still now iam getting error.the error message also i pasted here.plz rectifie my problem,plz.iam faceing this problem since several hours.plz help me. the error message is
Msg 206, Level 16, State 2, Line 5
Operand type clash: uniqueidentifier is incompatible with int
Msg 206, Level 16, State 2, Line 9
Operand type clash: uniqueidentifier is incompatible with int