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.
| Author |
Topic |
|
xlncsql
Starting Member
3 Posts |
Posted - 2010-03-06 : 11:34:13
|
| HI here the function I have created to split the string ex:'m1,m2,m3'to be splitted as m1,m2,m3. I have sucessfully created function but when use the function with a string it gives me NUll o/p can you guyz help me out with it create function fun_split(@string varchar(20))RETURNS char(5)begindeclare @b int,@c varchar(5), @d varchar(5) set @d = replace('@string',',','.') set @b=0 while(@b<4) begin set @c=parsename(@d,@b) set @b=@b+1return (@c) endendSELECT DBO.fun_split('M1,M2')Gives me null O/P if this not right way doing can you explane me y? |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-03-06 : 12:21:07
|
replace('@string',',','.')replace(@string,',','.') No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
xlncsql
Starting Member
3 Posts |
Posted - 2010-03-06 : 21:57:08
|
| I did dat too stillit returns me null.I guess I am using sclar functions so I made use of TVF table value function so here is my codealter function fun_split1(@string varchar(20))RETURNS @tab table( t varchar(10))asbegindeclare @b int, @c varchar(10), @d varchar(10), @x varchar(10)insert @tabselect @c set @d = replace(@string,',','.') set @b=len(@d) while(@b<4) begin set @c=parsename(@d,@b) set @b=@b+1 end returnend can you identtifie mistakes in this |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|
|
|