Can you define a new column in a SQL Server table which auto-generates Unique Identifiers for new rows?

Viewed 6907

Auto-increment columns in SQL Server get populated automatically; is it possible to define a UniqueIdentifier column to auto-generate on insert without the use of a trigger?

This will be a secondary unique key on the table. I need to create it because we need a public primary key now which can be used within a query string.

Legacy infrastructure still relies on the old int primary key. Given that the old infrastructure creates the record in the first place, I would like SQL Server to transparently create the secondary GUID key on insert - if at all possible.

Many thanks

2 Answers
Related