Pages

Thursday 27 October 2011

Run SQLCMD from SQL 2008 management studio query window

Microsoft embedded sqlcmd to run thru query-window. Now you can run SQLCMD without enabling xp_cmdshell from SQL management Studio. ( As you know, it is risky to enable this surface area configuration parameter ).

Open Management Studio -> Query -> SQLCMD Mode
Now, you can run a sqlcmd statements from a query window like below -
!!sqlcmd -S<ServerName> -E -Q"select * from sysfiles"

If you don't have a tool to run query against multiple database servers. No worries !! You can add your all database servers as a linked server in a server and run SQLCMD to query against multiple servers.

If you have more than 50 servers, there are many SQL diagnosis tools are available in the market. I worked with idera multi query tool. It is easy to use. There are a lot other things can be done using this tool. You can get more details here -
http://www.idera.com/Product-Tour/SQL-admin-toolset/SQL-Multi-Query/




No comments:

Post a Comment

Popular Posts

Search This Blog