Linking identical tables in different databases...

  • Hi,

    I've got two databases that are identical apart from one is the live, and one is the archive.

    My problem is that I need to link two identical tables from both databases so it appears seamlessly as one.

    Does anyone have any ideas on how to achieve this?

    Thanks

    Steve

  • Have you consider a view with union in it?

  • You can use a union query here is an example

    SELECT * FROM Database1.dbo.TableName

    UNION

    SELECT * FROM Database2.dbo.TableName

  • Thanks for replies.

    I've tried a union but keep getting a collation error.

    Steve

  • There is a way to specify the collation with the query.  I dont have books online at work with me (I'm in an oracle place right now).

    I suggest

    Make sure you run sp_linkserver (?? spelling?)

    I think the query goes something like

    select f1, f2, f3 from table1 with LATIN_1

    or something like that.  that is probably wrong, but might help.

    You'll need to "match" collations if you have different defaults on the 2 different machines.

    If you're in a dotnet world, you could

    DataSet ds1 = getDataFromDB1();

    DataSet ds2 = getDataFromDB2();

    ds1.Merge(ds2);

    something like that.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply