Previous Topic

Next Topic

Inhoudsopgave

Book Index

NewID

NewID( [flag] )

NewID returns a GUID. Possible flag values are:

If no flag is included, the default value 0 is used.

Example

select NewID( 0 ) -- 7efb62ad51814b68bc69f36540661643

select NewID( 1 ) -- 658692f7-8799-4036-98ae-f36540661643

select NewID( 0x0 ) -- 0x32697c7f374cc54f67baf34016436665

Differences

On MS SQL Server, NewID has no flag parameter. The output is always the string without ‘0x’ prefix, but including 4 dashes (flag = 1 in ASE)

The flag 0 values and 0x0 can be simulated on MS SQL Server:

-- simulates flag = 0

select Replace( Convert( varchar(36), NewID() ), '-', '' )

-- simulates flag = 0x0

select '0x' + Replace( Convert( varchar(36), NewID() ),'-', '' )