November 6, 2011 at 1:23 am
DECLARE @Sname CHAR(11) = 'A,B,C,D,E,F'
SELECT
split = SUBSTRING(@Sname, position.i, 1)
FROM (VALUES (1), (3), (5), (7), (9), (11)) AS position (i)
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
November 6, 2011 at 1:45 am
How to split the following string ?
Note: Without using split function,dynamic sql and xml
Declare @Sname Varchar(Max)
Set @Sname='A,B,C,D,E,F'
November 6, 2011 at 4:53 am
thanks and the following string will not work for yours solution
Declare @Sname Varchar(255)
set @Sname='SQL SERVER,ORACLE,MYSQL'
Need query urgent
November 6, 2011 at 5:53 am
satishthota (11/6/2011)
thanks and the following string will not work for yours solutionDeclare @Sname Varchar(255)
set @Sname='SQL SERVER,ORACLE,MYSQL'
Need query urgent
DECLARE @sname VARCHAR(255) = 'SQL SERVER,ORACLE,MYSQL';
SELECT
SUBSTRING(@sname, N.n, CHARINDEX(string.comma, string.csv, N.n + 1) - N.n - 1)
FROM
(
SELECT
v.number
FROM master.dbo.spt_values AS v
WHERE
v.[type] = N'P'
AND v.number BETWEEN 1 AND DATALENGTH(@sname)
) AS N (n)
CROSS APPLY
(
VALUES (CHAR(44), CHAR(44) + @sname + CHAR(44))
) AS string (comma, csv)
WHERE
SUBSTRING(string.csv, N.n, 1) = string.comma
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply