문제

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