How to Create a SQL Server Table with a FILESTREAM Column

To create a table with a FILESTREAM column for storing storing varbinary(max) binary large object (BLOB) data as files on the file system on a FILESTREAM enabled Database, run the following code:

CREATE TABLE [dbo].[FS_Table]
(
[Id] [int] IDENTITY(1,1) NOT NULL,
[UI] UNIQUEIDENTIFIER ROWGUIDCOL NOT NULL UNIQUE,
[FS_Data] [varbinary](max) FILESTREAM NULL
)

A table that has FILESTREAM columns must have a nonnull unique column with the ROWGUIDCOL property (in this example it is the [UI] column). If you try to create a table that has FILESTREAM columns without specifying a nonnull unique column with the ROWGUIDCOL property, like the following example code:

CREATE TABLE [dbo].[FS_Table2]
(
[Id] [int] IDENTITY(1,1) NOT NULL,
[FS_Data] [varbinary](max) FILESTREAM NULL
)

...you will get the following error:

Msg 5505, Level 16, State 1, Line 1
A table that has FILESTREAM columns must have a nonnull unique column with the ROWGUIDCOL property.

filestream_column_rowguidcol_error_create_table

Related articles:
How to Enable FILESTREAM on the SQL Server Instance
How to Enable FILESTREAM on an Existing SQL Server Database
How to Create a FILESTREAM Enabled SQL Server Database
How to Add a FILESTREAM Column to an Existing SQL Server Table