Thursday, March 22, 2012

Computed column formulae...2000 vs 2005

My head hurts!

I have a wicked database upgrade mechanism that works broadly like this:

    Master database schema is scanned into an object model then saved to an XML file.

    Sometime later...XML file is loaded back into object model and target database schema is scanned into another instance of this object model

    CompareSchemas routine takes both object models as input, compares them, and outputs a collection of Actions needed to bring the target in line with the master i.e. it works out all the DDL statements necessary to synchronize the database structure.

My problem is that I need to have this working seamlessly between 2000 and 2005 - our master development is still in SQL Server 2000 and will be until all our customers have moved up to 2005 (who knows how long that will take), but we have to allow new customers to run with 2005.

At the moment my upgrade mechanism always states that computed columns have changed. It seems that 2005 formats the formulae for computed columns differently to how 2000 did:

SQL 2000 version:

([bygroup] + 2 * [bysubgroup] + 4 * [byexchangecode] + 8 * [byitem])

SQL 2005 version:

((([bygroup]+(2)*[bysubgroup])+(4)*[byexchangecode])+(8)*[byitem])

Short of writing an expression parser to identify the fact that these two formulae are identical (which I REALLY don't have time for!), is there any way to get 2005 to format the formula in the same way as 2000?

Anyone?|||Any one at all? |||

I don't know of anyway to force sql2k5 to give you the sql2k format. However, wouldn't it be as simple as a replace (i.e. replace('sql2k5 format','sql2k format)).

No comments:

Post a Comment