Life with SQL
Experiences with Sql server
Friday, June 27, 2008
Executing the Same Query across all Databases
Eg:
Declare @sql varchar(1000)
set @Sql = 'select * from Contacts'
select 'use ' + name +
' ' + @sql from master.dbo.sysdatabases where dbid > 4
Copy the Statements to a new window and execute it.
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
Visitors Count
Links
sql 2008 Features
http://www.mssqltips,com
http://www.sqlteam.com
Blog Archive
►
2009
(4)
►
February
(1)
►
January
(3)
▼
2008
(11)
►
August
(4)
►
July
(3)
▼
June
(3)
Executing the Same Query across all Databases
Backup Report for the Server
Script for Changing the Job Owners across all the ...
►
April
(1)
►
2007
(5)
►
May
(3)
►
March
(1)
►
February
(1)
►
2006
(9)
►
October
(1)
►
September
(2)
►
August
(3)
►
July
(3)
Do you find this Blog useful
No comments:
Post a Comment