Keep in mind that BCP runs in the command-line window which uses your OEM code page. So that cedilla is likely to be interpreted as something else, and then it goes downhill from there.
Change '¸'
to nchar(184)
to avoid the issue.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi.
I am using BCP utility to transfer data from SQL table to a delimited file.
Below is the example of the query used:
BCP "SELECT 1 as First,
quotename(COUNTRY,'""') as COUNTRY, STATUS, QUOTENAME('¸','""') as last FROM TableName " queryout "path of file" -T -S servername -d DBInstance -b 500 -c -C 65001 -t~
In the query the last character is ¸ - i mean QUOTENAME('¸','""')
But when the file is generated, the last character is coming as ?
what causes the character change while doing a BCP ?
Keep in mind that BCP runs in the command-line window which uses your OEM code page. So that cedilla is likely to be interpreted as something else, and then it goes downhill from there.
Change '¸'
to nchar(184)
to avoid the issue.
How did you view the file to determine the value was ?. That is like a display problem in your viewer and not an output problem from BCP.
Your viewer is displaying ? because it doesn't know how to display the value 184.
Hi,
>"SELECT 1 as First,quotename(COUNTRY,'""') as COUNTRY, STATUS, QUOTENAME('¸','""') as last FROM TableName "queryout "path of file"
When I try to test this sql statement in a database (Chinese_PRC_CI_AS) different from the default server collation (SQL_Latin1_General_CP1_CI_AS), the last character is coming as ? in returned results. Then executed the BCP command to output the data to the file and got the same result.
I Change '¸' to nchar(184) as Erland suggested, and the problem was solved.