UniqueIdentifier: NEWID() system function
1> -- UniqueIdentifier: NEWID() system function
2>
3> CREATE TABLE MyTable (MyID UniqueIdentifier NOT NULL DEFAULT NewID()
4> , MyDescription nVarChar(50) NOT NULL)
5>
6> INSERT MyTable (MyID, MyDescription)
7> VALUES ('2BD9307D-5AAD-417C-AE3A-C1ACDCA0F6C9', 'Explicitly provided GUID')
8>
9> INSERT MyTable (MyID, MyDescription)
10> VALUES (DEFAULT, 'SQL Server generated GUID')
11>
12> SELECT * FROM MyTable
13> GO
(1 rows affected)
(1 rows affected)
MyID MyDescription
------------------------------------ -----------------------------------------
2BD9307D-5AAD-417C-AE3A-C1ACDCA0F6C9 Explicitly provided GUID
2EFB8F36-D459-4C82-8F41-47501DDBB219 SQL Server generated GUID
(2 rows affected)
1>
2>
3> drop table MyTable
4> GO
1>
Related examples in the same category