UniqueIdentifier are either explicitly provided or they are generated by the NEWID() system function : UniqueIdentifier « Constraints « SQL Server / T-SQL






UniqueIdentifier are either explicitly provided or they are generated by the NEWID() system function

 


6> CREATE TABLE MyTable (MyID UniqueIdentifier NOT NULL DEFAULT NewID()
7>           , MyDescription nVarChar(50) NOT NULL)
8>
9> INSERT MyTable (MyID, MyDescription)
10> VALUES ('2BD9307D-5AAD-417C-AE3A-C1ACDCA0F6C9', 'Explicitly provided GUID')
11>
12>
13> select * from MyTable;
14> select * from MyTable;
15> GO

(1 rows affected)
MyID                                 MyDescription
------------------------------------ --------------------------------------------------
2BD9307D-5AAD-417C-AE3A-C1ACDCA0F6C9 Explicitly provided GUID

(1 rows affected)
MyID                                 MyDescription
------------------------------------ --------------------------------------------------
2BD9307D-5AAD-417C-AE3A-C1ACDCA0F6C9 Explicitly provided GUID

(1 rows affected)
1>
2>

 








Related examples in the same category