赞
踩
记录Sqlserver中字符串中有特殊字符,记录了一下解决的方法,希望对你有用。
我是直接执行下面的前四句
--tab 9 回车13 换行10 空格32 ' " , : ; .
update Inventoty set name=replace(name,char(9),'')
update Inventoty set name=replace(name,char(10),'')
update Inventoty set name=replace(name,char(13),'')
update Inventoty set name=replace(name,char(32),'')
update Inventoty set name=replace(name,'''','')
update Inventoty set name=replace(name,'"','')
update Inventoty set name=replace(name,',','')
update Inventoty set name=replace(name,':','')
update Inventoty set name=replace(name,';','')
update Inventoty set name=replace(name,'.','')
--看ASCII码
print ASCII('a')
SET TEXTSIZE 0;
-- Create variables for the character string and for the current
-- position in the string.
DECLARE @position INT, @string CHAR(8);
-- Initialize the current position and the string variables.
SET @position = 1;
SET @string = 'New Moon';
WHILE @position <= DATALENGTH(@string)
BEGIN
SELECT ASCII(SUBSTRING(@string, @position, 1)),
CHAR(ASCII(SUBSTRING(@string, @position, 1)))
SET @position = @position + 1
END;
GO
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。