how to parse the string in a particular column sql server2005

Posted by Raj_chennai under Sql Server on 1/26/2012 | Points: 10 | Views : 1474 | Status : [Member] | Replies : 7
how to split the string in the columns in the sql server2005

raj


Responses

Posted by: Gow.net on: 1/26/2012 [Member] Starter | Points: 25

Up
0
Down
give any example

gowthaman8870226416

Raj_chennai, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Blessyjees on: 1/27/2012 [Member] Bronze | Points: 25

Up
0
Down
hi,

your issue is not clear. Are you mentioned about to apply the split function in a particular column

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Raj_chennai, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raj_chennai on: 1/27/2012 [Member] Starter | Points: 25

Up
0
Down
yes i need to split the string by defining new regular expression...

raj

Raj_chennai, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raj_chennai on: 1/27/2012 [Member] Starter | Points: 25

Up
0
Down
actually i have a table named complaint in which i have a column named 'comment' in which i am getting the complaint from the customer. i need to split the strings in the column 'comment'......

raj

Raj_chennai, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Blessyjees on: 1/27/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi raj,

How will you split the comment, using any special character.

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Raj_chennai, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raj_chennai on: 1/27/2012 [Member] Starter | Points: 25

Up
0
Down
i want to split the string without any special character.........
consider an example, a table named complaint in which i have the column comment in which all the comments are already inserted with values like " in my laptop the harddisk got failed" ...now i am going to search for keywords like laptop and harddisk in the comment column of the table complaint. how to search for this keyword . is it possible to search by applying split without any special characters. how to do this ??

raj

Raj_chennai, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rkworlds on: 1/27/2012 [Member] Starter | Points: 25

Up
0
Down
CREATE FUNCTION dbo.Split (@sep char(1), @s varchar(512))
RETURNS table AS RETURN
(
WITH SampleTable(pn, start, stop) AS ( SELECT 1, 1, CHARINDEX(@sep, @s)
UNION ALL SELECT pn + 1, stop + 1, CHARINDEX(@sep, @s, stop + 1)
FROM SampleTable
WHERE stop > 0
)
SELECT pn, SUBSTRING(@s, start, CASE WHEN stop > 0
THEN
stop-start
ELSE 512 END) AS s
FROM SampleTable )

If this helps you .
Please "Mark as Answer"

Raj_chennai, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response