SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


multiple values from BATCH file


multiple values from BATCH file

Author
Message
yocki
yocki
SSC Rookie
SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)

Group: General Forum Members
Points: 33 Visits: 63
Hi,

I am creating a batchfile that calls SQL query in a file

the batch contains:
SET/P keyid1=Please enter multiple keyids:
echo %keyid1%
SQLCMD -S ttgfgs03 -U admin -P admin -ic:\mult_keyid.sql


the sql file contains:
select keyid, namereg, creation_date
from db_app.dbo.funloc where keyid IN '$(keyid1)'


Problem is variable "keyid1" is not passed correctly from batch file to SQL query. I have tried values:
('GL9300','GL9200')
'GL9300','GL9200' and
GL9300, GL9200
results in syntax error

How can I enter multiple keyids so that the sql query will run correctly and returns results?

thanks
shad.saleem41
shad.saleem41
SSC Rookie
SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)

Group: General Forum Members
Points: 25 Visits: 46
http://stackoverflow.com/questions/4871620/how-to-pass-multiple-params-in-batch
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search