can anyone please tell me the right way to insert values in the rowguid column of the table? I m using sql server management studio
+1
A:
use the NEWID()
function to generate one:
CREATE TABLE myTable(GuidCol uniqueidentifier
,NumCol int)
INSERT INTO myTable Values(NEWID(), 4)
SELECT * FROM myTable
or you can set it as a defualt value:
CREATE TABLE myTable(GuidCol uniqueidentifier DEFAULT NEWSEQUENTIALID()
,NumCol int)
INSERT INTO myTable (NumCol) Values(4)
SELECT * FROM myTable
KM
2010-04-12 19:18:58
+3
A:
You can Set NEWSEQUENTIALID() as Default in table
CREATE TABLE GuidTable
(
ID UNIQUEIDENTIFIER DEFAULT NEWSEQUENTIALID() PRIMARY KEY,
TEST INT
)
Read more about it here
Kronass
2010-04-12 19:19:08
A:
Assuming that you have a uniqueidentifier column rg in your table t which is set to be the rowguid:
INSERT INTO TABLE t (rg) VALUES (NEWID())
or
INSERT INTO TABLE t (rg) VALUES (NEWSEQUENTIALID())
Cade Roux
2010-04-12 19:20:08
A:
It's a uniqueidentifier column
You can send a value like "6F9619FF-8B86-D011-B42D-00C04FC964FF", or use NEWID/NEWSEQUENTIALID functions to generate one
gbn
2010-04-12 19:20:41
Please accept one of the answers then...
gbn
2010-04-14 05:32:52
NEWID may be the right answer but in management studion i just select its rowguid property to true and when i enter data to other fields except this, management studio itself enter the string like u mention above: 6F9619FF-8B86-D011-B42D-00C04FC964FF. so i came to know that i dont have to enter values in this field, it will be automatically generated by management studio when selecting column as rowguid
amby
2010-04-15 15:19:09