while (charindex('(', @tmp) > 0) begin set @iLeft = @iLeft + 1 set @tmp = substring(@tmp, charindex('(', @tmp)+1, Len(@tmp)) end while (charindex(')', @tmp) > 0) begin set @iRight = @iRight + 1 set @tmp = substring(@tmp, charindex(')', @tmp)+1, Len(@tmp)) end
--当括号恰好组队的时候,才能进行字段别名的处理 if (@iLeft = @iRight) begin set @iLeft = 0 set @iRight = 0 --不对这几个特殊字段作处理:CheckBox、DetailButton、Radio if (charindex('CheckBox', @tmp) = 0 and charindex('DetailButton', @tmp) = 0 and charindex('Radio', @tmp) = 0) begin --判断是否有别名 if (charindex('as', @tmp) > 0)--别名的第一种写法,带'as'的格式 begin set @tmp = substring(@tmp, charindex('as', @tmp)+2, len(@tmp)) end else begin if (charindex(' ', @tmp) > 0)--别名的第二种写法,带空格(" ")的格式