0

If execute against database it works! but trying build on Vs sql server project it doesn't.

CREATE TABLE [dbo].[Recebimento_Arquivo] (
    [RAr_Codigo]       INT                        IDENTITY (1, 1) NOT NULL,
    [Rar_ID_FS]        UNIQUEIDENTIFIER           DEFAULT (newid()) ROWGUIDCOL NOT NULL,
    [Rec_Codigo]       BIGINT                     NULL,
    [FAr_Codigo]       INT                        NOT NULL,
    [RAr_Arquivo]      VARBINARY (MAX) FILESTREAM NULL,
    [RAr_Dat_Cadastro] DATETIME                   CONSTRAINT [dnfRecebimentoArquivo_RArDatCadastro] DEFAULT (getdate()) NULL,
    CONSTRAINT [PK_Recebimento_Arquivo] PRIMARY KEY CLUSTERED ([RAr_Codigo] ASC) ON [FG_ARQUIVOS_DADO],
    CONSTRAINT [FK_Recebimento_Arquivo_FAr_Codigo] FOREIGN KEY ([FAr_Codigo]) REFERENCES [dbo].[Formato_Arquivo] ([FAr_Codigo]),
    UNIQUE NONCLUSTERED ([Rar_ID_FS] ASC) ON [FG_ARQUIVOS_DADO]
) FILESTREAM_ON [FG_ARQUIVOS_FS_01];

It results

Severity    Code    Description Project File    Line    Suppression State
Error       SQL71566: Filegroup: [FG_ARQUIVOS_FS_01] cannot not be set on both the Table: [dbo].[Recebimento_Arquivo] and the clustered Primary Key: [dbo].[PK_Recebimento_Arquivo].    
3
  • Clustered index/key is table itself - most likely you cannot set filegroup for it separately at all. Commented Mar 8, 2017 at 13:57
  • if I just omit filegroup on primary key it work, but need understand why expliciting filegroup on primary it doesn't work! Commented Mar 8, 2017 at 14:15
  • Problem is not primary, but clustered key. Clustered key is data (table) itself and it cannot be located in another filegroup than table one (they are the same data) - and likely sql server doesn't allow to set it in this case at all. Commented Mar 8, 2017 at 14:27

2 Answers 2

1

At first sight, looks to be a bug in VS SQL Server projects.

As other comments say, you cannot speecify different filegroups for clustered key and for table. But that's not what you do. The final filegroup specification is for the filestream data that you store in the varbinary(max) column. Based on the syntax description in Books Online, this should be valid - and the fact that this runs when you execute it on SQL Server directly confirms that.

Sign up to request clarification or add additional context in comments.

1 Comment

Is true this is a bug in Visual Studio to solve my problem in my project what I did was just omit the FileGroup in my primary key and the project compiled normally
0

Ans is in your error itself,

    Severity    Code    Description Project File    Line    Suppression State
Error       SQL71566: Filegroup: [FG_ARQUIVOS_FS_01] cannot not be set on both the Table: [dbo].[Recebimento_Arquivo] and the clustered Primary Key: [dbo].[PK_Recebimento_Arquivo].  

you need to have different FileGroup and Primary Key Identifier.

3 Comments

They are differents!
check other tables
They are differents! Table filegroup is FILESTREAM_ON [FG_ARQUIVOS_FS_01], and Primary key filegroup is [FG_ARQUIVOS_DADO].

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.