Link to home
Start Free TrialLog in
Avatar of LuckyLucks

asked on

GUID copied from one table to another

Hello EEE
I have a GUID value that is retreived from a table1 that I am trying to insert into table2. Both the source and destination tables have the datatype uniqueidentifier. However, on an insert to table2,  this column is being set to null. Can we copy guid columns from one table to another? Or is the issue something else.

declare @myGUIDsrc uniqueidentifier

select  @myGUIDsrc = column1  from table1  <---- only one row and GUID value is returned

insert into table2 (column1, column2) values (@myGUIDsrc , 'TEST')
Avatar of Raja Jegan R
Raja Jegan R
Flag of India image

Yes, we can insert GUID values from one table to another..
But you need to use another format to insert the records and use WHERE clauses as required..
insert into table2 (column1, column2) 
SELECT column1, 'TEST'
from table1

Open in new window

Avatar of LuckyLucks


The thing is I have these set up as a cursor.
Hi LuckyLucks,

I didn't get what you meant..
Can you kindly clarify..
Avatar of Tomas Helgi Johannsson
Tomas Helgi Johannsson
Flag of Iceland image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial