How can we give default value to unique identifier field in table ?

Showing Answers 1 - 2 of 2 Answers

MikeroSoft

  • Jul 30th, 2006
 

Question is not well formed :Although the IDENTITY property automates row numbering within one table, separate tables, each with its own identifier column, can generate the same values. This is because the IDENTITY property is guaranteed to be unique only for the table on which it is used. If an application must generate an identifier column that is unique across the database, or every database on every networked computer in the world, use the uniqueidentifier data type and the NEWID (Transact-SQL) or NEWSEQUENTIALID() function. The Database Engine does not automatically generate values for the column. To insert a globally unique value, create a DEFAULT definition on the column that uses the NEWID or NEWSEQUENTIALID function to generate a globally unique value.The column can be referenced in a select list by using the $ROWGUID keyword

Ritesh Medhe

  • Sep 19th, 2006
 

Hi

Regards

Its very simple. I presume that you are aware of creating tables in SQL SERVER. If you want a default value in uniqueidentifier column. Just open the table in design view in enterprices value at highlight the column at the bottom you will see the tab strip with multiple coulmn viz., Description, Default Value...

In default value column just type newid(). Your problem is resolved now SQL SERVER will automatically generate the new uniqueidentifier value and populate the uniqueidentifier column.

Thanks and Regards

Ritesh

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions