Error: A table that has FILESTREAM columns must have a nonnull unique column with the ROWGUIDCOL property.

The Error

I got this error when I tried to create a table with FILESTREAM column and an integer column with primary key, after enabling FILESTREAM at the Server Instance.

CREATE TABLE MTB_Images_FileStream
(
    ImageID INT PRIMARY KEY,
    ImageStream VARBINARY(MAX) FILESTREAM
)
Error: A table that has FILESTREAM columns must have a nonnull unique column with the ROWGUIDCOL property.

The Problem

As the error description says, while creating a table with a FILESTREAM column, the table should have a non-null unique column with the ROWGUIDCOL property. This is a mandatory requirement for creating a FILESTREAM table.

The Solution

The solution for this issue is to have a unique, non null, ROWGUIDCOL column instead of the INT PRIMARY KEY column or add it as an additional column. For my situation, I’ve replaced the primary key column with a uniqueidentifier not null ROWGUIDCOL unique default newid() column.

CREATE TABLE MTB_Images_FileStream
(
    ImageID uniqueidentifier not null ROWGUIDCOL unique default newid(),
    ImageStream VARBINARY(MAX) FILESTREAM
)

This solved the issue for me.

Reference


Leave your thoughts...

This site uses Akismet to reduce spam. Learn how your comment data is processed.