Command line parameter passing
Does anyone know if it is possible to pass a parameter to a script run
from the isql (Query Analyzer).
I have a large .SQL file that does a setup of a database and I would
like to pass it a parameter that is
A name of another database to create some views to.
If its not possible from the command line, Is it possible to set an
environment variable and check that
variable inside the .sql script.
Any help would be appreciated.You can use the OSQL command-line utility and pass a parameter as part of a
the query / command string (-q switch).
Lookup the OSQL syntax in Books Online.
David Portas
SQL Server MVP
--|||Thanks for the response.
I have been trying something like this.
isql -H%GSHost% -S%GSServer% -d%GSDB% -U%GSUser% -P%GSPassWord% -n -q
"declare @.Odb varchar(40);set @.Odb=' test ';print @.Odb" -i GsViews.sql
in the GSViews.sql I do
print @.Odb
So when I do this the first print (from the -q) works but the one in the
GSViews.sql (run by the -i) errors out stating that @.Odb does not exist.
No GSViews.sql is quite long and it needs to know what other database
name. Any idea?
David Portas wrote:
> You can use the OSQL command-line utility and pass a parameter as part of
a
> the query / command string (-q switch).
> Lookup the OSQL syntax in Books Online.
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment