Saturday, 30 June 2012

Generating a new GUID value for insert

The other day I needed to insert some records into a table but I received an error on a column called GUID.  This unique reference column required a value similar to the following: 1A2BBCA2-7D80-4F34-9EDF-025203A721A3. 

For a 100 records what on earth was I going to enter.  With a bit of searching on internet I found that using the command newid() allowed me to create new value (Thank you

So for example

insert into tableA
select newid(), column 1, column 2 from tableB

No comments:

Post a Comment