Question

does anyone know of a technique to decide the data type of a column at deploy time with SSDT / dacpac deployment, depending on what features are available on the target SQL Server instance? Concrete example:

CREATE TABLE [HasBlob] (
    [Id] INT PRIMARY KEY,
    [Guid] [uniqueidentifier] ROWGUIDCOL NOT NULL UNIQUE,
    [Data] VARBINARY(MAX) FILESTREAM NULL
)

In this case, I would like to be able to automatically fall back to a conventional VARBINARY(MAX) blob instead of a FILESTREAM if FILESTREAM is not enabled for the SQL Server instance.

Was it helpful?

Solution

One way would be to query the current database's filegroups via sys.data_spaces, for example:

IF EXISTS(SELECT * FROM sys.data_spaces WHERE type = 'FD')
BEGIN
-- use create statement with FILESTREAM
END; 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top