#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    2
    Rep Power
    0

    Insert several databases simultaneously


    Hi!

    I would like to insert a record into table for many databases(that are alike). Does anyone know how to do this in SQL?

    Thank you in advance!
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Location
    Binghamton, NY
    Posts
    22
    Rep Power
    0
    One way is to use replication.

    Another way is to use run multiple queries with the full database qualifier.

    If all the databases are on the same server:

    Insert into MyDatabase1.dbo.MyTable (Field1) values ('hello world');
    Insert into MyDatabase2.dbo.MyTable (Field1) values ('hello world');
    Insert into MyDatabase3.dbo.MyTable (Field1) values ('hello world')


    If they are on different servers then you can create Linked Servers and the queries would look something like this:

    Insert into MyDatabase1.dbo.MyTable (Field1) values ('hello world');
    Insert into Myserver2.MyDatabase2.dbo.MyTable (Field1) values ('hello world');
    Insert into MyServer3.MyDatabase3.dbo.MyTable (Field1) values ('hello world')

IMN logo majestic logo threadwatch logo seochat tools logo