質問

I have set newid() to many tables as primary key, which is also refereed as foreign key at various places.

is it safe to convert nweid() to uniqueidentifier?

is there any chances of datalost?

役に立ちましたか?

解決

You don't actually convert, NEWID() returns an uniqueidentifier:

NEWID (Transact-SQL)

Creates a unique value of type uniqueidentifier.

A separate note, though: Be wary of using uniqueidentifiers as primary keys if you do not have a separate clustered index. Since uniqueidentifiers are not sequential, your inserts will have worse performance than if using a sequentially incrementing key.

他のヒント

It is impossible to convert newid () to uniqueidentifier because IT ALREADY IS ONE. So there is no conversion.

If you read the documentation:

http://technet.microsoft.com/en-us/library/ms190348.aspx

it says:

Return Types uniqueidentifier

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top