Menu

#4 *Interactive* script variable substitution for MSSQL

open
nobody
None
5
2011-02-21
2011-02-21
Paolo Zaboi
No

In Oracle SQLplus you can create your own scripts with dinamic variable management. This mean simply that when dba runs a script the system ask to the user the variable value to continue script execution.

This can be an example of a running script session:
----------------
[oracle@myserver MAN_SCRIPTS]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Mon Feb 21 12:36:00 2011
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SQL> @session_status --Here i'm running an exaple script to view session status (in freetds we use :r scriptname)
Session Id ? >> 67856 --The script is asking for a variable (the session id) to continue execution (can't do this in freeTDS!!!)
....
then the script give back results about the session required.
----------------------------------------------------------------------------

This feature is not supported in Microsoft T-SQL sqlcmd official cli client and is not supported in freeTDS too.

Introducing this feature in a next release of FreeTDS could be really GREAT to improve DBA's management possibilities.

This is a usable script syntax example we hope for next release:

:prompt $myvar 'Insert Database Name >>'
exec sp_helpdb '$myvar' ---show db infos

So an imaginary unix session could be somethign like:

[oracle@myserver MAN_SQLSCRIPTS]$ tsql -S MYSQLSERVER -U MYUSER -P MYPW
1> :r db_info.sql
Insert Database Name >> Northwind

... and we have infos about Northind db from sp_helpdb stored procedure

Hope to see something similar in next freetds release. For us is really necessary.

Thanks.
Paolo.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.