BCP无法导出,错误为“无法解析列级别归类” [英] BCP fails to export with error "Unable to resolve column level collation"
问题描述
我已经彻底搜索了Stack Overflow以及许多其他资源,但仍有问题。这是我的导出脚本,在Cygwin下运行:
I've thoroughly searched Stack Overflow as well as many other resources but still have an issue. Here's my export script, running under Cygwin:
#!/usr/bin/env bash
#-*- coding: cp1255; -*-
bcp "declare @billing_types table(k int null, t varchar(14)
collate SQL_Latin1_General_CP1255_CI_AS)
insert @billing_types
values (null, 'לא פעיל')
,(1, 'אשרי')
,(2, 'צ׳ק')
,(3, 'הוראת קבע')
declare @standing_order_status table(i int null, s varchar(14)
collate SQL_Latin1_General_CP1255_CI_AS)
insert @standing_order_status
values (null, 'אין')
,(4, 'מבותל')
,(3, 'לא מאושר')
,(2, 'ממתין')
,(1, 'מאושר')
select billing_company_id
,internal_company_name
, t collate SQL_Latin1_General_CP1255_CI_AS as payment_type_string
,isnull(company_email, '') collate SQL_Latin1_General_CP1255_CI_AS as email
,company_fax
,company_address
,company_comments
,invoice_send_with_details
,invoice_send_fax
,invoice_print
,cc_name
,cc_number
,cc_cvv
,cc_id
,cc_expire
,bank_number
,bank_branch
,bank_account
,bank_hoshen
,s collate SQL_Latin1_General_CP1255_CI_AS
from billing_companies
join @billing_types bt on bt.k = payment_type
join @standing_order_status os on os.i = bank_standing_order_status" \
queryout billing-companies.csv -t"," -r"\n" -S server -T \
-U user -P password -f ./billing-companies.fmt
以下是格式文件:
9.0
20
1 BIGINT 0 1 "" 1 billing_company_id ""
2 VARCHAR 0 1000 "" 2 internal_company_name SQL_Latin1_General_CP1255_CI_AS
3 VARCHAR 0 14 "" 3 payment_type_string SQL_Latin1_General_CP1255_CI_AS
4 VARCHAR 0 200 "" 4 email SQL_Latin1_General_CP1255_CI_AS
5 VARCHAR 0 100 "" 5 company_fax SQL_Latin1_General_CP1255_CI_AS
6 VARCHAR 0 4000 "" 6 company_address SQL_LATIN1_GENERAL_CP1255_CI_AS
7 NTEXT 0 1 "" 7 company_comments SQL_LATIN1_GENERAL_CP1255_CI_AS
8 BIT 0 1 "" 8 invoice_send_with_details ""
9 BIT 0 1 "" 9 invoice_send_fax ""
10 BIT 0 1 "" 10 invoice_print ""
11 VARCHAR 0 200 "" 11 cc_name SQL_LATIN1_GENERAL_CP1255_CI_AS
12 VARCHAR 0 50 "" 12 cc_number SQL_LATIN1_GENERAL_CP1255_CI_AS
13 VARCHAR 0 50 "" 13 cc_cvv SQL_LATIN1_GENERAL_CP1255_CI_AS
14 VARCHAR 0 50 "" 14 cc_id SQL_LATIN1_GENERAL_CP1255_CI_AS
15 VARCHAR 0 50 "" 15 cc_expire SQL_LATIN1_GENERAL_CP1255_CI_AS
16 VARCHAR 0 100 "" 16 bank_number SQL_LATIN1_GENERAL_CP1255_CI_AS
17 VARCHAR 0 100 "" 17 bank_branch SQL_LATIN1_GENERAL_CP1255_CI_AS
18 VARCHAR 0 100 "" 18 bank_account SQL_LATIN1_GENERAL_CP1255_CI_AS
19 INT 0 1 "" 19 bank_hoshen ""
20 varchar 0 14 "" 20 standing_order_status SQL_LATIN1_GENERAL_CP1255_CI_AS
归类与数据库中的归类匹配。当我在工作室中运行查询时,我获得了预期的结果,没有警告。
The collation matches the collation in the database. When I run the query in the studio, I'm getting the expected result, no warnings.
也许这里有一个警告:数据库使用单字节史前希伯来语编码。 ..我不知道Cygwin,或任何人后,它是不是试图在编码之间转换。然而,我已经doublechekced,我做了我的部分。也就是说
Perhaps here's a caveat: the database uses single-byte prehistoric Hebrew encoding... and I'm not sure whether Cygwin, or anyone later after it isn't trying to convert between encodings. However I've doublechekced that I did my part properly. I.e. the script file is itself in cp-1255.
如果我从脚本中删除了希伯来文的所有提及,那么它会工作。所以,我猜这是必须的问题,但是,我不知道我将如何解决它。
It works if I remove all mentions of Hebrew from the script. So, I'm guessing this must be the problem, however, I've no idea of how would I solve it.
推荐答案
您是否尝试使用-C开关指定特定的代码页?
Have you tried using the -C switch to specify a specific code page?
这是来自Books Online的BCP语法页面:
Here's the BCP syntax page from Books Online:
http://msdn.microsoft.com/en-us/library/ms162802.aspx
看这里,看起来你可能想使用代码页1255:
Looking here, it looks like you may want to use code page 1255:
http://msdn.microsoft.com/en-us/library/ms186356(v = sql.105) .aspx
HTH。
这篇关于BCP无法导出,错误为“无法解析列级别归类”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!