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

If the post helped you, please share it:
Pin It

1 comment to How to Create a SQL Server Table with a FILESTREAM Column

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">