How to get command line argument when running a script through ISQL

How to get command line argument when running a script through ISQL

Post by Ender » Fri, 24 Dec 1999 04:00:00



Hi,
  Pretty much the command line explains itself. I would like to pass a
parameter to a sql script when invoking it through isql. How can I do
that. Something similiar to &1 in Oracle. ?

i.e.

isql -i select_me.sql a_table_name

select_me.sql..follows...
select owner
from   sysobjects
where  type = 'U'
  and  name = &1

--
Ender Wiggin

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

How to get command line argument when running a script through ISQL

Post by DaveSat » Fri, 24 Dec 1999 04:00:00


Write a stored procedure instead of a script:

isql -U%2 -P%3 -S%1 -d%4 -Q"EXEC sp_myproc %5"

--
Thanks,
David Satz
Principal Software Engineer
Hyperion Solutions
(using VB6 SP3/MTS/SQL Server 6.5 SP5a)
(Please respond to the newsgroup.)


Quote:> Hi,
>   Pretty much the command line explains itself. I would like to pass a
> parameter to a sql script when invoking it through isql. How can I do
> that. Something similiar to &1 in Oracle. ?

> i.e.

> isql -i select_me.sql a_table_name

> select_me.sql..follows...
> select owner
> from   sysobjects
> where  type = 'U'
>   and  name = &1

> --
> Ender Wiggin

> Sent via Deja.com http://www.deja.com/
> Before you buy.


 
 
 

How to get command line argument when running a script through ISQL

Post by Itzik Ben-Ga » Fri, 24 Dec 1999 04:00:00


You can create a batch file that contains a script similar to this one:
isql /E /Q"select * from testdb..%1"
And call that batch with a parameter, e.g. mybatch table1.

--
Itzik Ben-Gan
SQL Server MVP
Hi-Tech College, Israel

http://www.mcse.org.il/isql


Quote:> Hi,
>   Pretty much the command line explains itself. I would like to pass a
> parameter to a sql script when invoking it through isql. How can I do
> that. Something similiar to &1 in Oracle. ?

> i.e.

> isql -i select_me.sql a_table_name

> select_me.sql..follows...
> select owner
> from   sysobjects
> where  type = 'U'
>   and  name = &1

> --
> Ender Wiggin

> Sent via Deja.com http://www.deja.com/
> Before you buy.

 
 
 

1. running isql from command line

I am having difficulty running isql from a command line.

isql -U sa -e -P -i CreateDB.sql

fails with the error message:

Login failed for user 'sa'. Reasong: Not associated with
a trusted SQL Server connection.
DB-Library: Login incorrect.

I have tried setting up another user with appropriate
priveleges user the Enterprise manager, but I get the
same error message. Any ideas?

Thanks,
Adam

2. Do you know MVS and/or DB2? Oracle Opportunities Inside

3. running isql from the command line...

4. XML Funcitonality through COM

5. Package runs in EM - doesn't from ISQL / Command LIne DTSRun

6. Macintosh Client ODBC Driver for Rdb

7. command line to run sql scripts (newbie)

8. Btrieve direct access in VB.NET

9. Automate running of SqlServer Script from command line

10. How to run SQL scripts via command-line?

11. How to run SQL script was command line.

12. How to run script file thro command line?