请帮我看一下!谢谢
请帮我看一下,谢谢。我想明白下面是什么意思及详细的变量取数原理
SELECT @startPosition = CHARINDEX(@str,@chrWhere,0)
IF @startPosition = 0
RETURN
SELECT @endPosition = CHARINDEX(@str,@chrWhere,@startPosition+1)
IF @endPosition = 0
RETURN
SELECT @attribute = SUBSTRING(@chrWhere,@startPosition+1,@endPosition-@startPosition-1)
SELECT @startPosition = CHARINDEX(@str,@chrWhere,@endPosition+1)
IF @startPosition = 0
RETURN
SELECT @endPosition = CHARINDEX(@str,@chrWhere,@startPosition+1)
IF @endPosition = 0
RETURN
SELECT @start = SUBSTRING(@chrWhere,@startPosition+1,@endPosition-@startPosition-1)
SELECT @startPosition = CHARINDEX(@str,@chrWhere,@endPosition+1)
IF @startPosition = 0
RETURN
SELECT @endPosition = CHARINDEX(@str,@chrWhere,@startPosition+1)
IF @endPosition = 0
RETURN
SELECT @end = SUBSTRING(@chrWhere,@startPosition+1,@endPosition-@startPosition-1)
------解决方案----------------------@startPosition是保存字符串@str在第一次@chrWhere中出现的位置
SELECT @startPosition = CHARINDEX(@str,@chrWhere,0)
IF @startPosition = 0
RETURN
--如果有则@endPosition保存第二次出现的位置
SELECT @endPosition = CHARINDEX(@str,@chrWhere,@startPosition+1)
IF @endPosition = 0
RETURN
--@attribute保存@str在@chrWhere中第一次与第二次位置中间的字符串
SELECT @attribute = SUBSTRING(@chrWhere,@startPosition+1,@endPosition-@startPosition-1)
--下面意思差不多