Sql server SQL脚本上的编码问题无法通过PowerShell脚本部署

Sql server SQL脚本上的编码问题无法通过PowerShell脚本部署,sql-server,powershell,encode,collation,ansi,Sql Server,Powershell,Encode,Collation,Ansi,我正在尝试使用一个脚本(带有合并到语句的数据插入)部署一个数据库(在SQL Server),该脚本在表中的列名为证书12 n°。部署使用PowerShell脚本。数据库属性具有芬兰语\u瑞典语\u CI\u AS用于排序 问题:手动插入使用列名。但是,当通过PowerShell脚本执行脚本时,会出现以下错误 无效的“列名”证书12 n�''' n.°被翻译为n�'° 问题:如何保持columan名称的原样(证书12 n°),并且仍然能够使用PowerShell脚本执行SQL脚本?还是其他更好的处

我正在尝试使用一个脚本(带有
合并到
语句的数据插入)部署一个数据库(在
SQL Server
),该脚本在表中的列名为证书12 n°。部署使用
PowerShell
脚本。数据库属性具有
芬兰语\u瑞典语\u CI\u AS
用于
排序

问题:手动插入使用列名。但是,当通过
PowerShell
脚本执行脚本时,会出现以下错误

无效的“列名”证书12 n�'''

n.°被翻译为n�'°

问题:如何保持columan名称的原样(证书12 n°),并且仍然能够使用
PowerShell
脚本执行
SQL
脚本?还是其他更好的处理非真实角色的方法

SQL
code:

MERGE INTO TableABCD target
USING (
SELECT  'Romania' AS COUNTRY, 'Head office ' AS [STORE NAME] ,'1234' AS [STORE ID], 'dsfsdf' AS Address, NULL AS [Certificate 11 n°] , NULL AS [Certificate 121 n°], NULL AS [Certificate _issue date] , 2015 AS YEAR, 6 AS MONTH, '201506' AS YM UNION
SELECT  'Spain' AS COUNTRY, 'Head office' AS [STORE NAME] ,'1122' AS [STORE ID], 'sdfsdf' AS Address, NULL AS [Certificate 11 n°] , NULL AS [Certificate 121 n°], NULL AS [Certificate _issue date] , 2015 AS YEAR, 6 AS MONTH, '201506' AS YM UNION
SELECT  'UK' AS COUNTRY, 'Head office' AS [STORE NAME] ,'1243' AS [STORE ID], 'sdfdf ' AS Address, NULL AS [Certificate 11 n°] , NULL AS [Certificate 121 n°], NULL AS [Certificate _issue date] , 2015 AS YEAR, 6 AS MONTH, '201506' AS YM UNION
SELECT  'Italy' AS COUNTRY, 'Head office' AS [STORE NAME] ,'1514' AS [STORE ID], 'dsfdfs' AS Address, NULL AS [Certificate 11 n°] , NULL AS [Certificate 121 n°], NULL AS [Certificate _issue date] , 2015 AS YEAR, 6 AS MONTH, '201506' AS YM
) source ON (target.COUNTRY = source.COUNTRY and target.[STORE ID] = source.[STORE ID] and target.ym = source.ym)
WHEN NOT MATCHED THEN
  INSERT (COUNTRY, [STORE NAME], [STORE ID], Address, [Certificate 11 n°], [Certificate 121 n°], [Certificate _issue date], YEAR, MONTH, ym)
VALUES (COUNTRY, [STORE NAME], [STORE ID], Address, [Certificate 11 n°], [Certificate 121 n°], [Certificate _issue date], YEAR, MONTH, ym)
WHEN MATCHED THEN
UPDATE SET
    target.COUNTRY = source.COUNTRY,
    target.[STORE NAME] = source.[STORE NAME],
    target.[STORE ID] = source.[STORE ID],
    target.Address = source.Address ,
    target.[Certificate 11 n°] = source.[Certificate 11 n°] ,
    target.[Certificate 121 n°] = source.[Certificate 121 n°] ,
    target.[Certificate _issue date] = source.[Certificate _issue date] ,
    target.YEAR = source.YEAR,
    target.MONTH = source.MONTH,
    target.YM = source.YM

)

看起来像是Ascii/Unicode转换错误。Powershell脚本文件使用的是什么编码?Powershell作为.Net,应该使用UTF-8处理所有事情。供应商也应该如此。我创建了一个测试表,并从Powershell中查询它,没有问题(
Invoke Sqlcmd-ServerInstance mysrv-Database mydb-Query'select[Certificate 12 n°]from test'
)。张贴代码,检查拼写。您发布的SQL代码仅引用名为
[Certificate 121 n°]
的字段,但您的错误消息引用的是
[Certificate 12 n°]
。也许你在什么地方掉了个角色?这不是问题所在。这只是一个示例代码。这是一个列名,我有
[Certificate 121 n°]
[Certificate 12 n°]
等等。看起来像是Ascii/Unicode翻译错误。Powershell脚本文件使用的是什么编码?Powershell作为.Net,应该使用UTF-8处理所有事情。供应商也应该如此。我创建了一个测试表,并从Powershell中查询它,没有问题(
Invoke Sqlcmd-ServerInstance mysrv-Database mydb-Query'select[Certificate 12 n°]from test'
)。张贴代码,检查拼写。您发布的SQL代码仅引用名为
[Certificate 121 n°]
的字段,但您的错误消息引用的是
[Certificate 12 n°]
。也许你在什么地方掉了个角色?这不是问题所在。这只是一个示例代码。这是一个列名,我有
[Certificate 121 n°]
[Certificate 12 n°]
等等。