views:

22

answers:

1

I've got a database from SQL Server 2005 that I am programmatically attaching to an instance of SQL Server 2008 R2, then re-establishing replication on some tables (via some pre-baked scripts that have worked for a small lifetime) with another server still running SQL Server 2005.

Suffice it to say it's just a particularly convoluted business requirement.

Interestingly enough, the replication fails on a particular SQL Server Agent job with an error "Invalid column name 'originator id'". From what I can understand from this link: http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/Q_24145417.html - the older database needs to have various bits and pieces upgraded to work correctly with SQL Server 2008 R2's replication. That upgrade process is as simple as running the stored procedure sp_vupgrade_replication: http://technet.microsoft.com/en-us/library/ms188741.aspx

Question 1: Why is there ANY information about replication baked into the database I am attaching?! My understanding was that the distribution database contained the entirety of replication information. I have deleted and re-attached a non-upgraded copy of the database to make sure it still didn't work to make sure I wasn't going insane.

Question 2: I know there are some procedures that get executed to upgrade the database to a certain compatibility level when you attach a DB to a newer version of SQL Server. Why isn't this stored procedure run?

Question 3: What exactly is this stored procedure changing? Is there any way I can find out any more than the MSDN article is offering me? I haven't tried it, but I'm pretty sure SQL Profiler will just tell me that it is executing sp_vupgrade_replication and not give me any details of the queries it is running.

+2  A: 

Question 1: It is the responsibility of the Publisher database to mark transactions for replication in its transaction log. The Log Reader Agent then monitors the Publisher's transaction log, looking for marked transactions, and copies those to the Distribution database. See: sp_replcmds and sp_repldone for some additional details.

Question 2: My guess (and it's only a guess) would be that since the procedure upgrades both system and user databases, it is not automatically run during an attach operation.

Question 3: You can view the details of the procedure yourself.

use msdb
go
sp_helptext 'sys.sp_vupgrade_replication'
go
Joe Stefanelli
I'm not sure I understand your answer to question #1. By Publisher database do you mean the DB being published? Or an actual database entity separate from it?My question #1 is more of a design one - why is it that the version-specific information about replication that caused this failure part of my database, rather than msdb? It's not like a compatibility level where you can have multiple databases running at different versions. You try to replicate an old database without upgrading, and it fails in a hugely obtuse fashion. Just doesn't make sense to me.
phyllis diller
In other news, thanks! I did not know you could get the exact text of stored procedures with sp_helptext. Perils of on-the-job training..
phyllis diller
@phyllis diller: When I say Publisher, I do mean the DB being published.
Joe Stefanelli