Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 how to execute insert statement to multiple DB's

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2008-04-21 : 14:35:41
I have the following insert how can i execute to multiple databases on same server:

insert into Tablerecords(labelkey,moduletype,english,spanish,updatedby)
values('hypUnderConstruction','MENU','Under Construction','Under Construction','admin')

databases: db1,db2,db3,db4,db5 etc

Thanks.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-21 : 15:17:56
Make a request at Spirit to add this functionality into SSMSToolPak
http://www.sqlteam.com/forums/pop_profile.asp?mode=display&id=10839



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-22 : 04:56:05
Use Db1
query
Go
Use Db2
query
Go
.
.
.

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-22 : 05:11:02
or use sp_Msforeachdb stored procedure
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-22 : 05:26:33
quote:
Originally posted by visakh16

or use sp_Msforeachdb stored procedure



It is undocumented
I wonder if they are supported in SQL Server 2008

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2008-04-25 : 04:27:47
or use the 3-part-reference in a dSQL

insert into db1.dbo.tablerecords...
select...



--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -