简体   繁体   中英

SQL Server Data Tools (SSDT) - Decide data type at deploy time?

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.

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; 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM