Autogenerate GUID in SQL Table

Hi,
Today I was working on SQL Table creation and I had a requirement to generate a UniqueIdentifier automatically whenever a record is inserted into the table.

We can achieve this requirement by having Column datatype as ‘UniqueIdentifier’ and Default Value or Binding of the column property should be set to ‘newid()’

Hope this helps.

Happy Coding

Gopinath

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s