SQL Clone
SQLServerCentral is supported by Redgate
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: 3330 | Views in the last 30 days: 5
Related Articles

SQL Server Long Query Script

SQL Server Long Query Find Script


by mistake one Script on Master

by mistake one Script on Master


Script system stored procedures in master?

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


where my Master Key and certificate is stored.

where my Master Key and certificate is stored.


Mastering SQL Server Profiler

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

linked server