带SQL Server的char \回车符的Proiblem [英] Proiblem with char \ carriage return with SQL Server

查看:138
本文介绍了带SQL Server的char \回车符的Proiblem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

(对不起,我的英语水平)

(Sorry for my english)

我实际上使用Oracle数据库开发了一个应用程序,但是我们必须将其迁移到SQL Server.

I developp actually an application with Oracle database but we must migrate it to SQL Server.

应用程序正在使用RDO和DAO 3.51来访问数据.

The application is using RDO and DAO 3.51 to access the data.

所以我有一个问题:许多表的字段类型为text(Ms Access中的备忘录),其中包含数据类型:

So i have a problem : many tables have a field of type text (Memo in Ms Access) witch contain the types of data :

317 \
这是一个测试\ test \ 123456 \
测试结束\

但是,当我们将数据从Oracle或Access迁移到SQL Server时,SQL Server将 \回车符替换为 \ . (换句话说,当行以 \回车符终止时,他删除了回车符).因此数据变为:

317\
This is a test\test\123456\
End of test\

But when we migrate the data from Oracle or Access to SQL Server, SQL Server replace the \ carriage return by \. (in others terms, he delete the carriage return char when the line is terminated by \ carriage return). So the data become :

317 \这是一个测试\ test \ 123456 \测试结束\

问题,应用程序无法正常运行.

317\This is a test\test\123456\End of test\

With this problem, the application do not function properly.

所以我想在不替换此char的情况下将数据迁移到SQL Server.我不想更改应用程序的代码,因此数据必须像源数据库中显示的那样进行迁移. (实际上,唯一的解决方案是将 \回车符替换为 \ espace回车符

So i want to migrate the data to SQL Server with no replacement of this char. I not want to change the code of the application and so the data must migrate like they are presented in the source database. (Actually, the only solution is to replace the \ carriage return by \ espace carriage return

您是否有解决此问题的方法?

Do you have a solution for this problem ???

谢谢.

推荐答案

尝试将所有\实例替换为char(13)


更新mytable
set myfield = replace(cast(myfield as varchar(500)),'\',char(13))



或者您可以在实际填充表格之前将其替换为代码.

s 字符串

Try replacing all instances of \ with char(13)


Update mytable
set myfield = replace(cast(myfield as varchar(500)), '\', char(13))



Or you can replace it in your code before you actualy populate the table.

Dim s As String

s = 您好,这是一个测试\经过测试的测试"

s = "Hello this is a test\ Test workded"

Debug.Print(s.ToString.Replace( <字体color =#800000" size ="2">"\" ,Microsoft.VisualBasic.ControlChars.CrLf))

Debug.Print(s.ToString.Replace("\", Microsoft.VisualBasic.ControlChars.CrLf))


这篇关于带SQL Server的char \回车符的Proiblem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆