日期:2014-05-17 浏览次数:20586 次
declare @sql varchar(1000)
set @sql= 'bbbbbb<asdfasd>aaa<bcd>aaa<asdfasd>dfasdf'
declare @val varchar(10),@wz int
set @wz=CHARINDEX('<',@sql)
while(@wz>0)
begin
set @val=SUBSTRING(@sql,CHARINDEX('<',@sql),charindex('>',@sql)-CHARINDEX('<',@sql)+1)
set @sql=REPLACE(@sql,@val,'')
set @wz=CHARINDEX('<',@sql)
end
print @sql
/*
bbbbbbaaaaaadfasdf
*/
declare @sql varchar(1000)
DECLARE @i INT
SET @i=1;
set @sql= 'bbbbbb<asdfasd>aaa<bcd>aaa<asdfasd>dfasdf'
WHILE(@i>0)
BEGIN
DECLARE @ibegin INT;
DECLARE @iEnd INT;
SELECT @ibegin=CHARINDEX('<',@sql)
SELECT @iEnd=CHARINDEX('>',@sql)
IF(@ibegin>0 AND @iEnd>0)
BEGIN
SELECT @sql=REPLACE(@sql,SUBSTRING(@sql,@ibegin,@iEnd-@ibegin+1),'')
END
SET @i=CHARINDEX('<',@sql);
IF (@i<=0)
BEGIN
PRINT @sql
END
END