Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to enter values in rowguid column?

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

like image 503
amby Avatar asked Apr 12 '10 19:04

amby


People also ask

How do I add a value to a specific column?

INSERT INTO Syntax 1. Specify both the column names and the values to be inserted: INSERT INTO table_name (column1, column2, column3, ...)

How insert values into Uniqueidentifier column in SQL?

Use the NEWID() function to obtain a globally unique ID (GUID). INSERT INTO THAI_MK_MT_Log(GUID, Status) VALUES (newid(), 'S'). newid() function will generate an unique identifier each time. INSERT INTO THAI_MK_MT_Log(GUID, Status) VALUES (cast ('xxxxxxxx ....

How do you add values to a specific row?

If you want to add data to your SQL table, then you can use the INSERT statement. Here is the basic syntax for adding rows to your SQL table: INSERT INTO table_name (column1, column2, column3,etc) VALUES (value1, value2, value3, etc); The second line of code is where you will add the values for the rows.

How do you insert unique rows in SQL?

INSERT DISTINCT Records INTO New Tables In order to copy data from an existing table to a new one, you can use the "INSERT INTO SELECT DISTINCT" pattern. After "INSERT INTO", you specify the target table's name - organizations in the below case.


1 Answers

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 default value:

CREATE TABLE myTable(GuidCol uniqueidentifier DEFAULT NEWSEQUENTIALID()
                    ,NumCol int)
INSERT INTO myTable (NumCol) Values(4)
SELECT * FROM myTable
like image 187
KM. Avatar answered Sep 20 '22 23:09

KM.