Problem with SSMS generated DDL (table with filestream)

  • Hi, I restored an external DB into a SQL Server 2008 R2 SP2 instance. I want to structure it (in terms of data location) as I want. I've tried some methods but I have finally found out that the simplest way to do it was to generate the script (via SSMS), change the code where it's needed, drop the restored database and recreate it using the modified script.

    I'm experiencing a weird problem :

    Multiple tables, all using filestreams have their DDL looking like this in the script generated by SSMS :

    CREATE TABLE [dbo].[ClaimDocuments](

    [doc_PK] [uniqueidentifier] NOT NULL,

    [doc_desc] [varchar](100) NOT NULL,

    [doc_clmfk] [uniqueidentifier] NOT NULL,

    [doc_FileGUID] [uniqueidentifier] ROWGUIDCOL NOT NULL,

    [doc_file] [varbinary](max) FILESTREAM NOT NULL,

    CONSTRAINT [PK_ClaimDocuments] PRIMARY KEY CLUSTERED

    (

    [doc_PK] 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] FILESTREAM_ON [FileStreamGroup1]

    GO

    Note that the last field is varbinary(max).

    I am getting this error:

    Cannot use TEXTIMAGE_ON when a table has no text, ntext, image, varchar(max), nvarchar(max), varbinary(max), xml or large CLR type columns.

    I don't understand why the TEXTIMAGE_ON close is coming there, but I know that if I remove it, the table create works perfectly.

    Can somebody help me ?

  • Did you have a column which was of a blob type outside of filestream at some point?

  • As I said, it's an external DB for an application developped by another company. I just took their .BAK file and restored it. I don't know the history of that DB.

  • Yep got the external DB, but not that it was developed by a 3rd party.

    The most likely culprit is that there once was a column which was of blob type outside of filestream, (probably the current filestream column) and it was altered to use filestream still leaving behind in the metadata the textimage option of the create table, or the column was dropped still leaving behind the metadata etc.

  • And I suppose the only way to "sanitize" is to make a clone table, copy data from the currently used table and switch ... There is no way to clean the metadata dictionary ?

  • Correct, it would be a drop and re-create of the table to flush the metadata into the new schema definition.

    Or create, import, drop, rename, which is the same as the above just keeps your data.

  • By the way, I generated the whole database script and suppressed the references to TEXTIMAGE_ON... I now get this error

    CREATE INDEX failed because the following SET options have incorrect settings: 'ANSI_PADDING'.

    I suppose it is related... ??

  • There is somewhere in the script setting it to OFF when it needs to be ON or to ON when it needs to be OFF, general rule of thumb is to have it ON.

    http://msdn.microsoft.com/en-us/library/ms187403.aspx

  • Yes, just before an index creation... But I'm very surprised because it's a script generated via SSMS, and I can't get to it working at once :w00t:

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply