IF(OBJECT_ID('tempdb..#TMP')) IS NOT NULL
BEGIN
TRUNCATE TABLE #TMP
DROP TABLE #TMP
END
CREATE TABLE #TMP
(
str11 VARCHAR(200)
)
DECLARE @Area VARCHAR(500)
SET @Area = '0-60,60-90,90-120,120-160,160-200,200-300,300-400,400-99999999'
IF(CHARINDEX(',',@Area)>0)
BEGIN
SET @Area = 'INSERT INTO #TMP
SELECT * FROM (SELECT '''+REPLACE(@Area,',',''' as str11 UNION ALL SELECT ''')+''') A'
END
ELSE
BEGIN
SET @Area = 'INSERT INTO #TMP SELECT * FROM (SELECT '''+@Area+''' as str11) A'
END
PRINT @Area
EXEC(@Area)
SELECT * FROM #TMP