Unique Identifier in SQL Server

While working with Filestream datatype, I've addressed an issue with Unique Identifier column. Thought of sharing this with you all.

       File stream is a new datatype introduced in SQL Server 2008 to leverage the functionality of storing  the data into the database.

       Below is the syntax to create a table in the database,
 
CREATE TABLE [dbo].[DOC_details2](
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [F_Data] [varbinary](max) FILESTREAM  NOT NULL,
    [F_Name] [nvarchar](1000) NULL,
    [F_Date] [datetime] NULL,
    [RowGuid] [uniqueidentifier] ROWGUIDCOL  NOT NULL
)

        While creating the filestream storage table, we need to specify one column as uniqueidentifier and it's a mandatory functionality.

         My question now is, How can we insert the data in a unique identifier column?

Solution 1:   We need to use newid() in SQL Server to generate the GUID

ALTER TABLE [dbo].[DOC_details2] ADD  CONSTRAINT [DF_DOC_details2_RowGuid]  DEFAULT (newid()) FOR [RowGuid]
GO 


Solution 2: From C#, we can make it out the method System.Guid.NewGuid.

Cheers,
Venkatesan Prabu .J 
Head, KaaShiv InfoTech.
http://www.kaashivinfotech.com/