Friday, March 9, 2012

problem when i try to modifie a field of a table in transactional

Hy,
i have the following problem:
i try to modifie an article (table) in a context of transactional
replication with queue updating in two way:
1- first way with sp_repladdcolumn and sp_repldropcolumn:
add a temporary field to the article:
exec sp_repladdcolumn @.source_object='Alc_AllarmiCritici'
,@.column='TempTipoEvento'
,@.typetext='nvarchar(100) NULL'
,@.publication_to_add='Chironpubb',
@.force_reinit_subscription =1
copy the data of the original column in the temporary fields
update Alc_AllarmiCritici set TempTipoEvento=TipoEvento
drop th original column
exec sp_repldropcolumn
@.source_object='alc_allarmicritici',@.column='TipoE vento'
add a new empty column with the name and data type of the temporary
exec sp_repladdcolumn @.source_object='Alc_AllarmiCritici'
,@.column='TipoEvento'
,@.typetext='nvarchar(100) NULL'
,@.publication_to_add='Chironpubb'
copy the date from temporary colum in the new empty column
update Alc_AllarmiCritici set TipoEvento=TempTipoEvento
drop the temporary table
exec sp_repldropcolumn @.source_object='alc_allarmicritici'
,@.column='TempTipoEvento'
then, i start the snapshot agent
the update of the structure is delivered th the subscriver susccessfully
the problem was that the field now is in the last positon in the table and
not in the same position before the updating. Therefore applications doesnt
function becouse the position of the fields have changed.
Does anybody know how i can resove the trouble?
2 - I exclude from replication the article with sp_dropsubscription and
sp_droparticle , i modified the article and then i put the article in the
replication with sp_addsubscription and sp_addarticle.
In this case sincronization from publisher to subscriver is ok.
Sincronization from subscriver to publisher doesn't function. Should i
create triggers for queue updating?
help me please, thankyou
Luca Schiavon
MCSD
(developer)
Luca,
mostly the advice is to make your application not dependant on column order
and to use column names instead. If this is not possible, then you can
change the column order on the publisher and reinitialize the table (drop
the article and then readd).
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .

No comments:

Post a Comment