2016-03-23 17 views
2

Ich habe die folgende Tabelle Spalte:hinzufügen Filestream zu einer vorhandenen Tabellenspalte

[Content] [varbinary](max) NULL 

Und ich will es eine Filestream-Spalte machen, so habe ich versucht:

alter table dbo.Files 
    alter column Content add filestream 

Aber ich bekomme die Fehlermeldung:

Incorrect syntax near 'filestream'. 

ich habe auch versucht

alter table dbo.Files 
    alter column Content varbinary(max) filestream not null 

Aber ich habe den Fehler:

Cannot alter column 'Content' in table 'Files' to add or remove the FILESTREAM column attribute. 

Wie kann ich Filestream zu einer vorhandenen Spalte hinzu?

+0

ich Verdacht haben, können Sie eine weitere Spalte erstellen müssen „alter table dbo.Files Content_new varbinary (max) Filestream nicht null hinzufügen "Dann kopiere, was du in der ursprünglichen Spalte hast. –

Antwort

2

müssen Sie die folgenden (bezogen von here) tun:

/* rename the varbinary(max) column 
eg. FileData to xxFileData */ 
sp_RENAME '<TableName>.<ColumnName>', 'xx<ColumnName>' , 'COLUMN' 
GO 

/* create a new varbinary(max) FILESTREAM column */ 
ALTER TABLE <TableName> 
ADD <ColumnName> varbinary(max) FILESTREAM NULL 
GO 

/* move the contents of varbinary(max) column to varbinary(max) FILESTREAM column */ 
UPDATE <TableName> 
SET <ColumnName> = xx<ColumnName> 
GO 

/* drop the xx<ColumnName> column */ 
ALTER TABLE <TableName> 
DROP COLUMN xx<ColumnName> 
GO 
Verwandte Themen