user12861
user12861

Reputation: 2426

BCP: Unable to resolve column level collations

Running this:

bcp MyDb.dbo.uvwMyView out "c:\Test.txt" -SMyServer -T -c

I get this error:

SQLState = S1000, NativeError = 0
Error = [Microsoft][SQL Native Client]Unable to resolve column level collations 

Searching google finds many possible solutions, none of which work for me or have worked for any of the people they were proposed for. As with other cases posted online, the view causes no problems when I select from it in Management Studio and the results look normal (and have no special characters, I checked). The one text column in the results has collation SQL_Latin1_General_CP1_CS_AS. I have tried several options to bcp with no effect: -w, -CRAW, -COEM, -C850, -C437.

I'm using SQL Server 2005.

Upvotes: 6

Views: 34153

Answers (6)

jhowa1
jhowa1

Reputation: 131

I just ran into this issue and found a different solution. Due to a configuration mistake, the server name was not supplied to the BCP command. For sake of redundancy and documentation, this the message: "The error SQLState = S1 000, NativeError = 0 Error = [Microsoft][ODBC Driver 13 for SQL Server]Unable to resolve column level collations BCP copy out failed"

Change the a null server value specified in the Server (-S) parameter to the correct server name.

Upvotes: 0

namrta narula
namrta narula

Reputation: 11

Try this one:

declare @sql varchar(8000)
select @sql = 'bcp "select * from database_name.dbo.table_name" queryout      H:\Tempfile_DTU_proc\test1.csv -c -t, -T -S' + @@servername

exec master..xp_cmdshell @sql

Upvotes: 1

kͩeͣmͮpͥ ͩ
kͩeͣmͮpͥ ͩ

Reputation: 7856

I was using SQL 2005 tools against a SQL 2008 R2 database, and I got the same error when using datetimeoffset fields.

Upvotes: 0

Steven howes
Steven howes

Reputation: 9

I know this question is already answered but I'll add my 2 cents... I ran into this today, I had add a PRINT @VarableName and in researching I found this:

From MS Connect

Removing the PRINT fixed my problem.

Upvotes: 0

user12861
user12861

Reputation: 2426

Dropping the view and recreating it fixed the problem. Unfortunately this doesn't explain how the problem happened in the first place, or how to prevent it in the future. This isn't a satisfying solution, so if anyone knows a better answer, I'm still very interested in hearing it.

Upvotes: 1

Damir Sudarevic
Damir Sudarevic

Reputation: 22187

  • You may try to remote connect to the server and run the bcp without the -s option from there.
  • If the server collation is different from the database or column collation, try to create the format file and explicitly specify it in the bcp.

Upvotes: 0

Related Questions