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 |
rajnidas
Yak Posting Veteran
97 Posts |
Posted - 2013-10-24 : 03:19:25
|
hi everybodyhow to remove space left to right and right to leftif i give limit >60 for first 60 character; limit 60< second 60 characterresult would be check if space at 60 character if yes remove and go the 59 character check then space remove and 58 character check if there is charater then displayas well as after 60 character to till 120 for right spacewhat is sql code pls post it |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2013-10-24 : 03:24:00
|
please post sample data and required result KH[spoiler]Time is always against us[/spoiler] |
|
|
rajnidas
Yak Posting Veteran
97 Posts |
Posted - 2013-10-24 : 03:40:25
|
KINDLY NEED HELP.. CODE AS GIVEN BELOWDECLARE @REV VARCHAR(MAX);declare @v_firstsixty varchar(max);declare @v_aftersixty varchar(max);declare @Res1 varchar(500);declare @v_len int;declare @v_f2 int;SELECT @Res = replace(ISNULL(@Res,''),',','')set @v_len= LEN(@Res + @strCents)if @flag = 1 SET @REV = @Res + @strCents set @Res1 = (@REV) if @v_len <= 60 begin --set CHARINDEX( @res , @strcents) >=0 SET @REV = SUBSTRING(@Res + @strCents ,1,60) set @Res1 = (@REV) end else begin SET @REV = REVERSE(SUBSTRING(@Res + @strCents,1,60)) set @v_firstsixty=REVERSE(SUBSTRING(@REV,CHARINDEX('',@REV)+1,LEN(@REV))) set @Res1 = @v_firstsixty endif @flag = 2 begin set @REV = REVERSE(SUBSTRING(@Res+@strCents,1,60)) set @v_f2= len(@rev)--len(REVERSE(SUBSTRING(@REV,CHARINDEX('',@REV)+1,60))) set @v_aftersixty=SUBSTRING(@Res + @strCents,60,@v_len)--LEN(@StrFinal + ' '+ @strCents)) set @v_aftersixty=SUBSTRING(@Res+@strCents,@v_f2+2,LEN(@Res+@strCents)) set @Res1 = @v_aftersixty end if @flag = 0 BEGINSET @Res1 = @Res + @strCentsend-----*******************************************************SET @Res1 = LTRIM ( RTRIM(@Res1 )) RETURN @Res1END EXECUTE------select dbo.fn_spellnumber('12,34,56,789.35','L',1,0)select dbo.fn_spellnumber('12,34,56,789.35','L',1,1)select dbo.fn_spellnumber('12,34,56,789.35','L',1,2)RESULT 1: Twelve Crore Thirty Four Lakh Fifty Six Thousand Seven Hundred And Eighty Nine Thirty Five Cents (OK)RESULT 2 : Twelve Crore Thirty Four Lakh Fifty Six Thousand Seven HundrRESULT 3: d And Eighty Nine Thirty Five CentsRESULT WOULD BE IN ROUND FIGUREPLS......... |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
rajnidas
Yak Posting Veteran
97 Posts |
Posted - 2013-10-24 : 04:48:36
|
thanks sir, but remove left and right space using while loop |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-10-24 : 08:58:33
|
quote: Originally posted by rajnidas thanks sir, but remove left and right space using while loop
use LTRIm and RTRIm for that. no need of loop------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|
|
|