Syncronizing SQL Servers in t-sql code

  • Hello!

    Can anyone help me please.

    I have several database and I would like to synchronize all of them from one "Master" database.

    I'm not talking about the data in the database, just the field size, tablename, and so on.

    How do I do that?

    Any answers would be greatly appreciated

    - Lars


    -Lars

    Please only reply to this newsgroup. All mails would be bounced back.

  • If you do not need indexes, just table structures, you could, while the target is current and the tables do not yet exist on the target...

    SELECT * INTO TableName FROM TheMaster.dbo.TableName WHERE 1=2

    or while "TheMaster" is current

    SELECT * INTO OtherDatabase.dbo.TableName FROM TableName WHERE 1=2

    for each table. Either use a cursor, or SELECT ... against Information_schema.tables to generate many or one big dynamic SQL statement to keep you from having to manually type all the commands.

    Hope this helps



    Once you understand the BITs, all the pieces come together

  • You can synch database structures using SQL Compare: http://www.red-gate.com 

    Well worth the $$$ & a real time saver.

    If you need to do this automatically somehow, you may want to look at log shipping, but this will also synch data.

    Vik

Viewing 3 posts - 1 through 2 (of 2 total)

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