1

我已经彻底搜索了 Stack Overflow 以及许多其他资源,但仍然有问题。这是我的导出脚本,在 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

排序规则与数据库中的排序规则匹配。当我在工作室中运行查询时,我得到了预期的结果,没有警告。

也许这里有一个警告:数据库使用单字节史前希伯来语编码......我不确定 Cygwin 或以后的任何人是否没有尝试在编码之间进行转换。但是,我仔细确认了自己的工作做得很好。即脚本文件本身在cp-1255 中。

如果我从脚本中删除所有提到的希伯来语,它就会起作用。所以,我猜这一定是问题所在,但是,我不知道如何解决它。

4

1 回答 1

0

您是否尝试过使用 -C 开关来指定特定的代码页?

这是联机丛书中的 BCP 语法页面:

http://msdn.microsoft.com/en-us/library/ms162802.aspx

看这里,您可能想要使用代码页 1255:

http://msdn.microsoft.com/en-us/library/ms186356(v=sql.105).aspx

HTH。

于 2013-03-13T20:24:54.603 回答