Friday, February 24, 2012

failure to publish an indexed view logbased publication

i am trying to publish an indexed view logbased publication but I'm getting "must be a schema-bound view with at least a clustered index to be published as a log-based indexed view article."

The table has clustered index and the view is schema-bound.

this is the script for schemabinding

SETANSI_NULLSON

GO

SETQUOTED_IDENTIFIERON

GO

ALTERVIEW [nth].[musictracks1] withschemabinding

AS

SELECT autoid,idtrack,songname,singer,writer,composer,center

FROM nth.musictracks

GO

SETANSI_NULLSOFF

GO

SETQUOTED_IDENTIFIEROFF

GO

and this is for making the publication an indexed view logbased publication

execsp_addarticle

@.publication = N'lb_publication',

@.article = N'musictracks1',

@.source_owner = N'nth',

@.source_object = N'musictracks1',

@.type = N'indexed view logbased',

@.description =null,

@.creation_script =null,

@.pre_creation_cmd = N'none',

@.schema_option = 0x0000000008000001,

/* table name doesn’t have to be the same as view name */

@.destination_table = N'musictracks1',

@.destination_owner = N'nth'

GO

Any idea what is wrong?

Thanks,

Salah

If you want to use logbased for an indexed view, then you have to create a unique clustered index on the indexed view as the error msg indicates. if you just want to replicate the view schema, then you can used indexed view schema only.|||

can you tell how can I create a unique clustered index on the indexed view ?

Thanks

|||

you create an index on it like you do with any other table, for example:

create unqiue clustered index [uc_index1] on musictracks1 (autoid)

No comments:

Post a Comment