|
newid()
The
mathematical function
newid() returns an unique, 32 to 36
bytes long
GUID
(globally unique identifier) in two possible formats,
depending on the value specified in the parameter of the function.
By default newid() produces GUIDs without hyphens.
All other parameter values will create GUIDs with hyphens, making them
better readable.
The output of newid() without hyphens can be converted into
a 16 bytes long
binary
format, using the function
strtobin.
If the format with hyphens is chosen for this conversion, the result is
NULL.
The function newid() can be used in
triggers,
defaults
and
rules.
newid() is a
T-SQL
extension which can be executed by any
user.
The function newid() is available in
ASE
starting with version 12.5.1.
Syntax of the Mathematical Function newid()
The Parameter of the Mathematical Function newid()
"option"
The parameter "option" can take on of the following values:
-
0 or empty - the resulting GUID is human readable and contains
no hyphens.
This option can be used for converting the output into the
datatype
varbinary.
-
1 - Output of the human readable GUID with hyphens
-
0x0 - Output of the GUID as varbinary datatype.
Example for the Mathematical Function newid()
select newid(1)
go
------------------------------------
1bf5c5b3-4191-4ebb-b0ee-a6c3c5350f2a
The result is a hyphenated globally unique identification string (GUID),
which is unique even beyond server boundaries.
See also:
ASE T-SQL - Aggregate Functions, Mathematical Functions, abs(), acos(), asin(), atan(), atn2(), ceiling(), cos(), cot(), degrees(), exp(), floor(), log(), log10(), pi(), power(), radians(), rand(), round(), sign(), sin(), sqrt(), tan().
|