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
 SQL Server Development (2000)
 spaces as part of a parameter

Author  Topic 

kennisf
Starting Member

1 Post

Posted - 2002-03-22 : 11:47:11
Hi,

The following batch-file is called from an external program. One parameter is given to the batchfile: an articlenumber, called pro_nr. The script returns the cost related to this product.

@echo off
set dbase=cs3pladm
set pro_nr=%1 %2 %3 %4 %5 %6 %7 %8 %9
F:\mssql7\binn\isql -h-1 -U scheme -P password -d %dbase% -Q " select cost from stockh where product like '%pro_nr%'"

The batch-file is working well for article numbers without any spaces like 'CYC123' and for article numbers with 1 space in it like 'CYC 123 HF'. However, most article numbers contain consecutive spaces like 'CYC GRI 767001'.

We already tried set pro_nr=%* but this gave no result for any of the article numbers.

I would appreciate the help, Filip

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-03-22 : 11:56:51
See if this helps:

@echo off
set dbase=cs3pladm
set pro_nr="%1" "%2" "%3" "%4" "%5" "%6" "%7" "%8" "%9"
F:\mssql7\binn\isql -h-1 -U scheme -P password -d %dbase% -Q " select cost from stockh where product like '%pro_nr%'"


Putting the quotes around each DOS parameter should treat each as an entity, so that multiple consecutive spaces aren't interpreted as a separate parameter. If this doesn't work (I'm not 100% sure it will), echo out the entire SQL string you're trying to pass to isql and see if it is syntactically correct (copy it and paste it into query analyzer and see if it runs). If you get a syntax error in QA, it should point out where the problems are, and you can modify the batch file to work around them.

Go to Top of Page
   

- Advertisement -