Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Passing parameters to sql script?

Author  Topic 

Lucy
Starting Member

4 Posts

Posted - 2005-09-22 : 21:17:37
Hi All,

Can we pass parameters into an sql script?
For example, I'd like to be able to do something like this:

C:> osql -SaServer -E -ianSqlScript.sql <parameter-1> <parameter-2>

And inside the anSqlScript.sql I want to do something like:

DECLARE @project VARCHAR(25)
DECLARE @directory NVARCHAR(520)

SET @project = <parameter-1>
SET @directory = <parameter-2>
....

I could not find any documentation on this.
Is this actually possible?

Thank you,
Lucy

rheitzman
Starting Member

16 Posts

Posted - 2005-09-23 : 12:28:21
Doesn't look like it to me. Do a >osql -? to see the syntax and 'osql utility' in books on line.

Creating VBS wrapper that re-write the script as needed wouldn't be too difficult - it could even prompt for the params.

Go to Top of Page

Lucy
Starting Member

4 Posts

Posted - 2005-10-03 : 20:28:42
Thank you for the reply.

I had searched for documentation on this but could not find any,
including doing osql -?
I was hoping this was one of the undocumented features of SQL Server :-)
Go to Top of Page
   

- Advertisement -