Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Select, Update, Delete, Insert etc.. in many servers using 1 query

By Lester Policarpio,

What if your boss wants you to insert or updated a record in a table in several servers? lets say 50 server what would you do? Open each and every servers and run the insert or update? that will take time if you have several servers. Let this script do the job for you..... All you have to do is to linked that server to the server where you will run the script,create this procedure, run this script and whalaaaaa done....

NOTE: for you to use this script first modify the query by changing single quotes with double quotes

If your query is

select name from master..sysdatabases where name = 'master'

when applying it to the script it must be

select name form master..sysdatabase where name = ''master''

example query :

syntax usp_linked_query 'db_name','db_owner','query'

operation: usp_linked_query 'master','dbo','select name from sysdatabases where name = ''master'''

update example

usp_linked_query 'db_name','db_owner','update table_name set col_name = ''value'' where condition'

*Always change single quotes to double quotes and enclose the whole query with ' '

Total article views: 3276 | Views in the last 30 days: 5
 
Related Articles
FORUM

by mistake one Script on Master

by mistake one Script on Master

FORUM

where my Master Key and certificate is stored.

where my Master Key and certificate is stored.

FORUM

Script system stored procedures in master?

Script my own sp's that are running as system stored procedures in master?

ARTICLE

Mastering SQL Server Profiler

SQL Server Profiler can troubleshoot a wide range of SQL Server issues, such as poorly-performing q...

FORUM

SQL Server 2005 script

SQL Server 2005 script

Tags
linked server    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones