DECLARE @val AS VARCHAR(MAX)
DECLARE @Delimiter AS VARCHAR(5)
SET @Val = '1,3,4,5,6,134,234,234,213,34'
--SET @Val = 'a, b, c, d, e'
SET @Delimiter = ','
SET @Val = @Val + @Delimiter
CREATE TABLE #Temp (val VARCHAR(50))
WHILE (@Val != '')
BEGIN
INSERT INTO #Temp
SELECT LTRIM(SUBSTRING(@val, 1,charindex(@Delimiter, @val)-1))
SET @Val = (CASE WHEN (LEFT(@val, 1) != @Delimiter) THEN SUBSTRING(@val, charindex(@Delimiter, @val) + 1, LEN(@Val)) ELSE '' END)
END
SELECT * FROM #temp
DROP TABLE #Temp
Captions
- Asp.Net (9)
- ASP.Net Tips (1)
- C# (7)
- Computer (1)
- Internet Explorer (5)
- Java Script (11)
- Shortcut Keys (4)
- SQL Programming - Common Mistakes (11)
- Sql Server (22)
- Sql Server Definitions (8)
- Sql Server Test (2)
- SSRS (2)
About Me
- Vasanth.S
- I'm just normal guy who like to travel, addicted to TV and Computer, Playing Computer Games and Watching Movies and many more. Have lot of idea and quote in life
My Blog List
-
-
Pass data from one page to another using post15 years ago
Blog Archive
-
▼
2009
(63)
-
▼
July
(12)
- Insert into Table with XML Value as Parameter
- Error Handling in Sql Server
- Procedure to find a given Number is Amstrong Numbe...
- Procedure to Upload CSV File to Table
- Basics of Sql Server - 2
- Basics of Sql Server - 1
- Working Hours between two Dates excluding Weekends
- No. of Saturday and Sunday between two Dates
- Getting Column value in a row with comma seperator
- Split the variable based on a demiliter
- Date Parameters
- Delete all Stored Procedure, Function and Tables i...
-
▼
July
(12)