Вы можете создать две таблицы вместо одной:
CREATE TABLE [dbo].[FileStreams](
[Id] [int] IDENTITY(1,1) NOT NULL,
[RowGuid] [uniqueidentifier] ROWGUIDCOL NOT NULL,
[Data] [varbinary](max) FILESTREAM NULL,
CONSTRAINT [PK_FileStreams] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
UNIQUE NONCLUSTERED
(
[RowGuid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] FILESTREAM_ON [FilestreamGroup]
GO
CREATE TABLE [dbo].[Files](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](1024) NULL,
[FileStreamId] [int] NOT NULL,
CONSTRAINT [PK_Files] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Files] WITH CHECK ADD CONSTRAINT [FK_Files_FileStreams] FOREIGN KEY([FileStreamId])
REFERENCES [dbo].[FileStreams] ([Id])
GO
ALTER TABLE [dbo].[Files] CHECK CONSTRAINT [FK_Files_FileStreams]
GO
Внешний ключ должен быть NO ACTION
. Позволяет создать INSTEAD OF
триггер для таблицы Files