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
 SQL Query

Author  Topic 

vmurali
Yak Posting Veteran

88 Posts

Posted - 2007-02-08 : 04:38:47
Hi,
Can anybody tell me how to split an column value. I have a table with rows number, name.

Sno Name
1 Varun Kumar
2 Abraham David

I need to get the value as
Sno Fname Lname
1 Varun Kumar



SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-08 : 04:42:36
With the help of the function here, SELECT" rel="nofollow">http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76033[code]SELECT Sno, dbo.fnParseString(2, ' ', Name) AS Fname, dbo.fnParseString(1, ' ', Name) AS Ename
FROM YourTable WHERE Sno = 1


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

vmurali
Yak Posting Veteran

88 Posts

Posted - 2007-02-08 : 04:54:50
Thanks for your quick reply. Is there any method we can get with using inbuild functions
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-08 : 04:56:48
Yes, the PARSENAME function, PATINDEX function, CHARINDEX function.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

vmurali
Yak Posting Veteran

88 Posts

Posted - 2007-02-08 : 05:54:56
how do we split "Ronald Francis Sebastian" using System Defined Function
Go to Top of Page

vmurali
Yak Posting Veteran

88 Posts

Posted - 2007-02-08 : 05:56:04
how do we split "Ronald Francis Sebastian" using System Defined Function as 'Ronald' 'Francis' 'Sebastian'
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-02-08 : 05:58:14
[code]declare @a varchar(50)

set @a = 'Ronald Francis Sebastian'

select parsename(replace(@a, ' ', '.'), 3), parsename(replace(@a, ' ', '.'), 2), parsename(replace(@a, ' ', '.'), 1)
[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -