从SQL Server选择数据时如何删除换行符? [英] How do I remove line feed characters when selecting data from SQL Server?

查看:354
本文介绍了从SQL Server选择数据时如何删除换行符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将包含换行符的数据插入数据库.然后,我检索该数据.我正在使用此脚本尝试从SQL中选择数据时删除换行符:

I insert data that contains a line feed character into the database. Then I retrieve that data. I am using this script to attempt to remove the line feed while selecting the data from SQL:

Select Replace(Replace stringname,char(10),'',char(32),'')) from tablename

替换功能似乎已执行,但不能正确删除换行符.

The replace function seems to execute, but it does not remove the line feed correctly.

推荐答案

您的陈述的语法不正确,也许您可​​以尝试使用以下方法:

The syntax of your statment looks wrong, maybe you can try with something like this:

Select Replace(Replace(@str,CHAR(10),''),CHAR(13),'')

内部替换取代LF,外部替换取代CR

The inner replace relaces LF and the outer replace replace CR

这篇关于从SQL Server选择数据时如何删除换行符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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