Вопрос

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