日期:2014-05-18 浏览次数:20758 次
create function delstr(@t varchar(100)) returns varchar(100) as begin select @t=stuff(@t,number,1,CHAR(32)) from master..spt_values where type='p' and number between 1 and len(@t) and number in( charindex(char(9),@t,number), CHARINDEX(char(10),@t,number), CHARINDEX(char(13),@t,number), CHARINDEX(char(28),@t,number), CHARINDEX(char(29),@t,number), CHARINDEX(char(30),@t,number), CHARINDEX(char(31),@t,number), CHARINDEX(char(127),@t,number) ) return replace(@t,CHAR(32),'') end go select dbo.delstr(' fasdfas'+CHAR(9)+'dfsdf sadf ') /* ---------------------------------------------------------------- fasdfasdfsdfsadf (1 行受影响) */ go drop function dbo.delstr