BCP SQL 2005 from a .BAT file


any ideas?

If i execute this.

C:\bcp>bcp "SELECT * FROM db1.dbo.table1 WHERE (title_code LIKE '%ABC%')" queryout c:\bcp\accounts.txt -c -t, -T -S
Starting copy...
935 rows copied.

it works,

If I place it in a Export_FTP.bat file.

bcp "SELECT * FROM db1.dbo.table1 WHERE (title_code LIKE '%ABC%')" queryout c:\bcp\accounts.txt -c -t, -T -S

ftp -s:c:\ftp_info.txt
It returns "0 rows copied." but is still succesful.

Thanks guys,
LVL 30
Brad HoweDevOps ManagerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

% sign represents whe variables in cmd script...
You can need handle the % to resolve the issue...
Change your where clause to with the following...

title_code LIKE '%%ABC%%'

bcp "SELECT * FROM db1.dbo.table1 WHERE (title_code LIKE '%%ABC%%')" queryout c:\bcp\accounts.txt -c -t, -T -S

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Brad HoweDevOps ManagerAuthor Commented:
Beautiful. Forgot the at % acts are variables in BAT.

Thanks a bunch.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.