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.
Author |
Topic |
Johnho008
Starting Member
24 Posts |
Posted - 2008-05-29 : 05:40:34
|
Hi,Just wanted to know if you can pass variable into OSQL command.i.eOSQL -E -S{Servernam} -d{database} -q "select * from table where userid = @userid"Thanks |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-05-29 : 13:06:01
|
You can via DOS code, so you'd have to wrap your osql call into a batch files. I believe you use % to indicate variables there. You'll need to do some research on the DOS code though as I'm a bit rusty.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
 |
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2008-05-29 : 15:20:22
|
set USERID=34234234OSQL -E -S{Servernam} -d{database} -q "select * from table where userid = %USERID%" elsasoft.org |
 |
|
Johnho008
Starting Member
24 Posts |
Posted - 2008-05-30 : 05:14:51
|
Thanks everyone,I ended up using SQLCMD command insteadSET /P UserName="Enter UserName"SET /P Costcentre="Enter Costcentre"sqlcmd -S{servername} -vUserName="%UserName%" -vCostcentre="%Costcentre%" -i {Input TSQL file}Worked like a dream allowing user input |
 |
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2008-05-30 : 10:13:00
|
i would have suggested using sqlcmd but you posted in the 2000 forum, so I assumed you didn't have sqlcmd available to you. elsasoft.org |
 |
|
|
|
|