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
 General SQL Server Forums
 New to SQL Server Programming
 spliting a column into two columns

Author  Topic 

maruti
Starting Member

1 Post

Posted - 2010-08-09 : 20:45:14

Hai i am working on sqlserver 2000. I need to split a column into two columns using delimiter space.

Can any one help me..

Ex:-
column_Name
sppz, kualampur
pesde, phunigners

column like that i need result like

column1
sppz
pesde

column2
kualampur
phunigners

thankyou for advance


khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-08-09 : 21:46:30
[code]select col,
col1 = left(col, charindex(',', col) - 1),
col2 = right(col, len(col) - charindex(',', col))
from yourtable[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-08-10 : 13:22:38
will format of string values in column be always consistent? ie. will there be a comma separating two words always?

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

Go to Top of Page
   

- Advertisement -