2016-03-23 4 views
0

Ich habe eine Tabelle auf einem vorhandenen SQL Server 2014-Datenbank wie folgt:Warum TEXTIMAGE_ON und machen Tabelle als Filestream

CREATE TABLE [dbo].[Files](
    [Id] [int] IDENTITY(1,1) NOT NULL, 
    [Content] [varbinary](max) NULL, 
    [Created] [datetime2](7) NOT NULL, 
    [Flag] [nvarchar](100) NULL, 
    [Key] [uniqueidentifier] NOT NULL, 
    [MimeType] [nvarchar](400) NOT NULL, 
    [Name] [nvarchar](400) NULL, 
    [Pack] [uniqueidentifier] NOT NULL, 
    [Slug] [nvarchar](400) NULL, 
    [Updated] [datetime2](7) NOT NULL, 
CONSTRAINT [PK_File] 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] TEXTIMAGE_ON [PRIMARY] 

Was TEXTIMAGE_ON ist und warum nicht nur [PRIMARY]?

Wie kann ich diese Tabelle ändern, um FileStream zu verwenden? So wäre es haben:

[Key] uniqueidentifier rowguidcol not null 
    constraint DF_File_Key default newid() 
    constraint UQ_File_Key unique ([Key]), 

Und

) filestream_on ??? 

UPDATE

Ich habe folgende TSQL:

exec sp_configure filestream_access_level, 2 
reconfigure 

alter table dbo.Files 
    set (filestream_on = 'default') 

alter table dbo.Files 
    alter column [Key] add rowguidcol; 

alter table dbo.Files 
    alter column Content filestream; 

alter table dbo.Files 
    add constraint DF__File__Content default (0x), 
     constraint DF__File__Key default newid(), 
     constraint UQ__File__Key unique ([Key]); 

go 

Aber wenn ich es laufen lasse, bekomme ich die Fehlermeldung: Falsche Syntax für die Definition des 'TA BLE 'Einschränkung.

Ich verwende "Standard", weil ich die Standarddateigruppe verwenden möchte.

Was fehlt mir?

Antwort

3

Von msdn:

SET (FILESTREAM_ON = { partition_scheme_name | filestream_filegroup_name | "default" | "NULL" }) 

Applies to: SQL Server 2008 through SQL Server 2016. Specifies where FILESTREAM data is stored. ALTER TABLE with the SET FILESTREAM_ON clause will succeed only if the table has no FILESTREAM columns. The FILESTREAM columns can be added by using a second ALTER TABLE statement.

Die TEXTIMAGE_ON standardmäßig auf den Tischen mit großen Spalten verwendet wird (nvarchar (max), varbinary (max) usw. als here erwähnt: TEXTIMAGE_ON is not allowed if there are no large value columns in the table. TEXTIMAGE_ON cannot be specified if <partition_scheme> is specified. If "default" is specified, or if TEXTIMAGE_ON is not specified at all, the large value columns are stored in the default filegroup. The storage of any large value column data specified in CREATE TABLE cannot be subsequently altered.)

+0

Ich habe gerade meine T-SQL zu einer Frage Update hinzugefügt ... Aber ich bekomme einen Fehler. Irgendeine Idee warum? –

+0

Wenn Ihr Fehler lautet: 'Standard FILESTREAM Dateigruppe ist nicht in der Datenbank verfügbar ' bearbeiten (für SQL Server 2014 :) Dann sollten Sie ausführen:' EXEC sys.sp_configure N'filestream Zugriffsebene', N'2 ' gehen' sonst poste deine Fehlermeldung hier. –

+0

Ich denke du meinst Level = 2? Ich habe meine Frage aktualisiert, aber es war bereits in 2. Ich habe diesen Fehler nach der Neukonfiguration. Nichts anderes als der Fehler, den ich gepostet habe –