sqlserver 中含有某字符串

查找 sqlserver 中字符串的ascii码
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 = '—销售定转子冲片及转子齿压板等(北京三一)'
WHILE @position <= DATALENGTH(@string)
   BEGIN
   SELECT ASCII(SUBSTRING(@string, @position, 1)),
      CHAR(ASCII(SUBSTRING(@string, @position, 1)))
   SET @position = @position + 1
   END
GO

发现特殊字符char(31),单元间隔符

查找sqlserver中是否含有该特殊字符

两种方案
select * from  GL_accvouch where cdigest like '%'+ char(31)+'%'
select * from  GL_accvouch where CHARINDEX(CHAR(31),cdigest)<>0

或者使特殊字符显示出来

select REPLACE(cdigest,char(31),'xx'),* from gl_accvouch

最后替换特殊字符

posted @ 2013-08-21 09:54  银杏叶儿  Views(3832)  Comments(0Edit  收藏  举报