Hello,
I am running a bcp command to export all data from one single table. One of the table field has the flower brackets at the begining and the end and the column is defined as of data type uniqueidentifier (length 16).
The original command that I used is :
c:\bcp dbo.Product out c:\product.csv -w -t"|" -r\n
The ProdID column in Product table have values like : {3E116F82-5E52-4EF9-9A97-8756EA6E9A16}
But in the out put file, the flower brackets are being omitted.
So, I tried the following query :
c:\bcp "Select ID,Name,"+'"{"+'+"convert(varchar(100),ProdID)"+'+"}"'+",ProdType,IsActive,TitleCode,CreationDate,CreatorID,AllowView,AllowRead,AllowWrite,AllowDelete,AdminURL,ReportProc from dbo.Product" queryout c:\Product16Feb.csv -w -t"|" -r\n
But it is giving the following error message:
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax
near ','.
SQLState = 37000, NativeError = 8180
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be
prepared.
The SQL statement is correct because when I run it individuall, it works but not with the bcp command.
I just want the ProdID column to have the flower brackets in the output file using bcp. How can I achieve this?
Many thanks
Ratan
You can define your SQL statement as a view and then BCP the view. Otherwise, consider editing the file after the BCP operation and applying the brackets then.
没有评论:
发表评论