Reputation: 587
Assume t1 and t2 are 2 tables , when I run sql query in microsoft sql studio , it generates k rows ,
select * from t1 join t2 on t1.colA = t2.colA where t1.colB like 'ab%'
but the same query when run through bcp generates n rows always less than k . What is wrong with the query in bcp ?
set DEST = C:\Users\userA\Desktop\exports
set BCPARGS =-c -t, -S <servername> -d <dbname> -U user1 -P passwd1 -e %DEST %errors.txt
bcp "select * from t1 join t2 on t1.colA = t2.colA where t1.colB like 'ab%'" queryout %DEST %csvname.csv %BCPARGS %
Upvotes: 1
Views: 224
Reputation: 587
I didn't know the fact that % is used to indicate a replaceable parameter in windows based terminal (cmd) . So, %% should be used in like part of sql query i.e like 'ab%%' instead of like 'ab%'
The first % indicates that the second % is part of a name rather than a replacable parameter just like escape sequence.
Upvotes: 1