SQLCMD Startup Script


SQLCMD can run a startup script defined by the environment variable SQLCMDINI.

Suppose you want to always execute the following query when you are connected to the server:

SELECT @@SERVERNAME, @@VERSION 


Place this command inside the init.sql file and define the following environment variable:

C:\SET SQLCMDINI=c:\sqlscripts\init.sql 


Then whenever you start a SQLCMD session, the script automatically executes and displays query output listing the server name and full version string.




Inside SQL Server 2005 Tools
Inside SQL Server 2005 Tools
ISBN: 0321397967
EAN: 2147483647
Year: 2006
Pages: 149

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net