Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use % in OSQL from batch file? 1

Status
Not open for further replies.

bknepher

Programmer
Jun 13, 2001
7
0
0
US
How can I use a "... NOT LIKE '%.gif'" (for example) in a batch file calling OSQL? The % is replaced by running the batch, thinking it is a replacable parameter. Trying % on the command line and using %1 in the quoted SQL query doesn't seem to work. It looks like it will but fails. If I double up the % "... NOT LIKE '%%.gif'" it again appears to be correct as one % is dropped but the query still fails.


 
For craps and giggles did you by-chance try using TWO percent signs in a row?

TR
 
I did (see original post). It echoed to cmd window looking like it should run but the results, if any, returned by osql were completely different than the same query cut and pasted into query analyzer.
 
Use -i parameter followed by an input file name instead of using -q / -Q (inline command). In this way, the text of the T-SQL is in a file and not "eaten" or mangled by batch.

TR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top