本文转自:https://example-code.com/sql/charset_convert_file_from_utf8_to_ansi.asp

CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @sTmp0 nvarchar(4000)
DECLARE @charset int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Charset', @charset OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END DECLARE @success int
EXEC sp_OAMethod @charset, 'UnlockComponent', @success OUT, 'Anything for 30-day trial.'
IF STR(@success) <> 1
BEGIN
EXEC sp_OAGetProperty @charset, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @charset
RETURN
END EXEC sp_OASetProperty @charset, 'FromCharset', 'utf-8'
EXEC sp_OASetProperty @charset, 'ToCharset', 'ANSI' -- We could alternatively be more specific and say "Windows-1252".
-- The term "ANSI" means -- whatever character encoding is defined as the ANSI
-- encoding for the computer. In Poland, for example, it would be the single-byte-per-char
-- used to represnt Eastern European language chars, which is Windows-1250.
EXEC sp_OASetProperty @charset, 'ToCharset', 'Windows-1252' EXEC sp_OAMethod @charset, 'ConvertFile', @success OUT, 'qa_data/txt/cafeUtf8.txt', 'qa_output/cafeAnsi.txt'
IF STR(@success) <> 1
BEGIN
EXEC sp_OAGetProperty @charset, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @charset
RETURN
END PRINT 'Success.' EXEC @hr = sp_OADestroy @charset END
GO

[转](SQL Server) Convert a File from utf-8 to ANSI (such as Windows-1252)的更多相关文章

  1. Sql Server CONVERT获取当前日期及日期样式

    Sql Server CONVERT获取当前日期及日期样式(转)(2012-06-06 12:00:24) 转载▼ // 标签: 杂谈 分类: SQL Sql Server CONVERT样式 获取当 ...

  2. Kettle建立数据库链接报错-'MS SQL Server' driver (jar file) is installed. kettle的bug,对于12.2而言

    1.链接sql server数据库报错 错误连接数据库 [My_vm_win_sql] : org.pentaho.di.core.exception.KettleDatabaseException: ...

  3. SQL Server CONVERT() 截取日期

    SELECT CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AMSELECT CONVERT(varchar(100), GETDATE() ...

  4. SQL SERVER – Attach mdf file without ldf file in Database

    Background Story: One of my friends recently called up and asked me if I had spare time to look at h ...

  5. SQL Server CONVERT() 函数(转)

    定义和用法 CONVERT() 函数是把日期转换为新数据类型的通用函数. CONVERT() 函数可以用不同的格式显示日期/时间数据. 语法 CONVERT(data_type(length),dat ...

  6. SQL Server ->> Enable Instant File Initialization(开启文件及时初始化)

    我们在安装SQL Server的时候会在指定SQL Server各个服务的运行启动账户的账户的时候看到底下有一个选项写着“Grant Perform Volume Maintenance Task p ...

  7. SQL Server CONVERT() 函数

    http://www.w3school.com.cn/sql/func_convert.asp 定义和用法 CONVERT() 函数是把日期转换为新数据类型的通用函数. CONVERT() 函数可以用 ...

  8. sql server convert 日期

    ),) --2016/11 ),) --2016-11-03 17:46:47

  9. 使用SQL Server CONVERT() 函数

    语法 CONVERT(data_type(length),data_to_be_converted,style) data_type(length) 规定目标数据类型(带有可选的长度).data_to ...

随机推荐

  1. [proposal][app]Watch your time!

    [Motivation] 很多时候,我们要去某个地方,尤其是第一次去的时候,都不知道什么时候出发,留出的时间够不够,会不会早到或者晚到.虽然地图软件能给出一些粗略的步行,公交,或者出租时间估计,但是每 ...

  2. AreaHttpControllerSelector 对 Web Api 实现 Area 路由控制

    结合此文章:http://www.cnblogs.com/wuhuacong/p/5828038.html using System; using System.Collections.Concurr ...

  3. 【算法python实现】 -- 不同路径

    原题:https://leetcode-cn.com/problems/unique-paths/ 问题描述 n行m列的表格,从a[0][0]出发,每次只能右移一步或者下移一步,求到a[n-1][m- ...

  4. Weekly Contest 133

    1030. Matrix Cells in Distance Order We are given a matrix with R rows and C columns has cells with ...

  5. 百度地图sdk---pc端

    <div class="map" style="width: 1196px;height: 500px;margin: 50px auto;"> & ...

  6. postgresql-distinct on理解

    PostgreSQL 的 distinct on 的理解 对于 select distinct on , 可以利用下面的例子来理解: create table a6(id integer, name ...

  7. elasticsearch5.6.3插件部署

    需要注意的是,5.x和2.x插件方面改动很大.参考:https://www.elastic.co/blog/running-site-plugins-with-elasticsearch-5-0.因为 ...

  8. salt-api return mysql返回的使用,记录操作日志

    说在前面 折腾这个搞了半天,现做下记录 安装依赖(操作只在master端) yum install mysql-python or pip install mysql-python master端本地 ...

  9. XAMPP中MySQL无法启动解决办法

    如图 问题出在mysql的路径上,其实报错已经讲得听清楚了 预期应该是这样 结果却是这样 所以解决办法当然就是修改这个路径,出现这个报错原因大多因为之前电脑装过mysql,所以电脑默认启动是原来的my ...

  10. java8之lambda表达式(2)-方法引用

    方法引用使用的地方也是在函数式接口,使用方法引用可以使代码更加简单和便捷 在如下代码中 根据List中字符串长度排序的代码可以写成如下: public static void test1_() { L ...