Error on BCP with LIKE in query

Error on BCP with LIKE in query

Post by Ian Robinso » Tue, 13 Aug 2002 16:26:47


Thanks. I had eventually got to figuring out that this was
the problem an all is working fine now

Quote:>-----Original Message-----
> Ian - it's not bcp or SQL Server.  It's the way the

command processor works
Quote:> with % signs.  It thinks they are the start of a

variable.  If you actually
Quote:>want to pass a % sign to a program as a parameter in this
way you need to
>double them up.

> So just change every % to %% and you're away
> #
>> Thank you for your input on this.  It has exposed a new
>> twist to me.  I have the bcp command in a cmd file and
>> when I run the cmd file is when I get the error.  If I
>> the code from the cmd file and paste it into a command
>> promt window and run it from there, as you have done in
>> your test, it works.  I have tried with a cmd file and
>> bat file and see the same behaviour on both.  Any idea
>> why? I am running on a Windows 2000 Professional OS.

>> Regards

>> Ian Robinson

>> >-----Original Message-----
>> >Hi Lan,

>> >There is no known issue on '%' character with BCP. I
>> performed a test
>> >on this issue, but I cannot reproduce the problem. A
>> simple query on the
>> >'orders' table of the sample database 'Northwind' is
>> performed in this
>> >test. Here's what I have done.

>> >1. Issue the command in the command prompt.
>> >Bcp "select 'change   ' , orderid, customerid from
>> Northwind.dbo.orders
>> >where customerid like 'H%'"  queryout c:\tttt.txt -
Usa -
>> t -c

>> >2. The screen will display 'Password:'.
>> >3. Specify the password of the account 'sa' to be
>> authenticated by the SQL
>> >Server.
>> >4. The operation succeeds. Open the tttt.txt file, I
>> see all the
>> >expected results there.

>> >The only difference between us is the account. Please
>> specify a account in
>> >your command and try again. If anything is unclear,
>> please let me know.

>> >Sincerely,

>> >Linda Deng
>> >Microsoft Support Engineer

>> >This posting is provided "AS IS" with no warranties,
>> confers no rights.

>> >.

> Neil Pike MVP/MCSE.  Protech Computing Ltd
> Reply here - no email
> SQL FAQ (484 entries) see
> ( in lib 7)
> or
> or
> or



1. Query slow over liked server


I have a problem with a query runing on a linked server.

When I execute the following on the target server the query takes about 2
UPDATE TableName
SET MarkedForXfer = 0
WHERE MarkedForXfer = 1

When I execute the following on a linked server from another server the
query takes about 30 mins
UPDATE SQLLinkedServer.Database.dbo.TableName
SET MarkedForXfer = 0
WHERE MarkedForXfer = 1

Has anyone got any Ideas why this would be?


2. Msg 234, insufficient result space to convert MONEY value to CHAR. HELP

3. Likes CAT and Sport Query

4. machine name & SYS(0)

5. ODBC, BCP Error: Unable to open BCP host data-file

6. Question on Product Registration

7. RDO 2.0 OpenResultset - Who knows what the problem is???

8. BCP Error: Connection is not enabled for BCP

9. BCP query out executed by xp_cmdshell works fine from query analyzer but fails from VB Component

10. Counting the number of satisfied LIKES in a SELECT statement

11. Query Designer encountered a Query error: Unspecified error,

12. Liked Server to SYBASE