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)
 query

Author  Topic 

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2011-02-18 : 10:43:07
[code]

I have a string like VT. GEREEK UHC, VELTA FUNCTION, TK 89737
I want to split these into



COl1 COl2 COL3 COL4
-------------- -------------- -------- -------
VT. GEREEK UHC VELTA FUNCTION TK 89737
[/code]

Thanks for your help

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-02-18 : 11:10:51
Does it have always four part only?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2011-02-18 : 11:12:03
Yes..it will always have four parts
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-02-18 : 12:03:58
select
parsename(col,4) as col1,
parsename(col,3) as col2,
parsename(col,2) as col3,
parsename(col,1) as col4
from
(
select replace(col,',','.') as col from table
) as t



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2011-02-18 : 13:23:50
Thanks madhivanan
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-02-21 : 03:17:52
quote:
Originally posted by sqlfresher2k7

Thanks madhivanan


You are welcome

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -