I came across a very strange issue with replication this weekend.
As a part of a release a new table was being created with extra columns and a view was created with the old table name that referenced the old column set (so as not to break old legacy applications). This table was replicated. The dev team provided us with scripts to setup replication. During the attempt to perform the snapshot I ran into some problems and so dropped the publication.
All of a sudden users started to complain that they could no longer see the view and couldn’t query the data. I looked, and sure enough the view was not there. Very strange. I told the users that I’d get it created again once replication was done. I redid the publication and the users called me saying not to worry, the view was back.
What the heck?
After digging through I found the cause of the issue. The dev had created the replication scripts and included a filter to eliminate certain columns. This replication then gets wrapped into an article view. In this case the dev had manually named the @view_name in sp_articleview to be the same as the view in the database. This caused SQL to drop the existing view and create it’s own. When the publication was dropped so was the view.
Here are the steps to repro this behavior:
Firstly I’m creating a view against the local table SQLMonitor.dbo.SQLBuilds
CREATE VIEW Bananas AS SELECT Build , [KB Article] , URL , Description , MajorBuild , MinorBuild FROM SQLMonitor.dbo.SQLBuilds
A quick select shows data:
Continue reading on SirSQL.net.