Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 split special charcter in string

Author  Topic 

Rameshwar
Starting Member

4 Posts

Posted - 2011-09-20 : 06:49:49
hi,
i have a string

declare @Name nvarchar(100)
select @name='ra,a:b'c:dflg,:hlf'

i want split character wise it

please help

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-20 : 07:14:39
so wat should be output?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Rameshwar
Starting Member

4 Posts

Posted - 2011-09-20 : 07:47:22
output should be

ra
a
b
c
dflg
hlf
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-20 : 08:05:32
as table of values you mean?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Rameshwar
Starting Member

4 Posts

Posted - 2011-09-20 : 08:14:25
Declare @name nvarchar(1000)

set @name='a,b:c,d:e,f,g:h'

actually i want comma and colon separated value means

a
b
c
d
e
f
g
h


Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-20 : 10:59:01
why is your delimiter not consistent? any ways here you go


Declare @name nvarchar(1000)

set @name='a,b:c,d:e,f,g:h'

SELECT Val
FROM dbo.ParseValues(REPLACE(@name,':',','),',') f


output
-------------------------
Val
----------------------
a
b
c
d
e
f
g
h



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -