Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

multiple values from BATCH file Expand / Collapse
Author
Message
Posted Monday, July 29, 2013 12:52 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, June 16, 2014 2:19 AM
Points: 14, Visits: 45
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

Post #1478449
Posted Tuesday, July 30, 2013 2:55 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, May 16, 2014 1:38 AM
Points: 9, Visits: 46
http://stackoverflow.com/questions/4871620/how-to-pass-multiple-params-in-batch
Post #1478884
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse