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)
 stored procedure for split csv values

Author  Topic 

kaarthikeyan
Starting Member

8 Posts

Posted - 2011-03-07 : 04:12:03
I need stored procedure for the following question
1.question
2.Output

1.ID Products

--------------------------------------------------------------------------

1 12, 45,35,40,52

2 10, 20,40,52,78



and I would like to have results as



2.ID Products

--------------------------------------------------------------------------

1 12

1 45

1 35

1 40

1 52

2 10

2 20

2 40

2 52

2 70



I would appreciate if someone could offer me some guidance here.


karthik k

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-03-07 : 04:15:52
refer to these 2 thread

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=25830&SearchTerms=CSVTable
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76033


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

Go to Top of Page

kaarthikeyan
Starting Member

8 Posts

Posted - 2011-03-07 : 04:29:11
in some rows the products exceeds beyond 50 and also it is not fetch the properly

karthik k
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-03-07 : 04:33:25
quote:
Originally posted by kaarthikeyan

in some rows the products exceeds beyond 50 and also it is not fetch the properly

karthik k



can you explain further ? Which function are you using ?


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

Go to Top of Page

kaarthikeyan
Starting Member

8 Posts

Posted - 2011-03-07 : 05:25:44
here i'm using ltrim,rtrim,substring function to split the values and also cursor

karthik k
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-03-07 : 05:26:52
You have decided to write your own code, instead of using a tested function above?


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

kaarthikeyan
Starting Member

8 Posts

Posted - 2011-03-07 : 05:30:44
yes

karthik k
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-03-07 : 05:31:14
Ok. Good luck.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

kaarthikeyan
Starting Member

8 Posts

Posted - 2011-03-07 : 05:32:33
hey peso tell some books and links to develop the sql knowledeg

karthik k
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-03-07 : 05:43:05
why don't you just use one of the function in the link ?


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

Go to Top of Page

kaarthikeyan
Starting Member

8 Posts

Posted - 2011-03-07 : 05:47:40
quote:
Originally posted by khtan

why don't you just use one of the function in the link ?


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





already i used that function only now i got my mistake due to datatype size it is show error i clear that

karthik k
Go to Top of Page
   

- Advertisement -