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
 Remove last digit from string.

Author  Topic 

hspatil31
Posting Yak Master

182 Posts

Posted - 2012-04-17 : 07:45:22
Dear All,

I have following query and I am getting following output.
If in fist colum last is - then it should remove from the column.
Please see the desired outpu.
Can anybody plz tell me how resolve this issue ?

SELECT
('1'+'-'+ISNULL(i.Country_Code,'')+'-'+ISNULL(i.Dialed_Digits,'')) AS INTERNATIONAL,
ISNULL(IN.Rate,0) AS Rate

FROM
tb_lcr_ierg i (nolock),
tb_lcr_int_nor_r_s IN (nolock),
.
.
.

Output:

1-213- 0.1265
1-355-4 0.0336
1-355-67 0.3181

Desired Output:

1-213 0.1265
1-355-4 0.0336
1-355-67 0.3181


Thanks and Regard's
Harish Patil

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-04-17 : 07:52:29
SELECT REPLACE(ISNULL('1-' + CountryCode, '') + ISNULL('-' + Dialed_Digits, ''), '- ', ' ') AS International
FROM ...



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

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-04-17 : 07:58:04
Try:
'1'+ISNULL('-'+i.Country_Code,'')+ISNULL('-'+i.Dialed_Digits,'') AS INTERNATIONAL


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-04-17 : 07:58:37



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

hspatil31
Posting Yak Master

182 Posts

Posted - 2012-04-17 : 09:17:52
Thanks All, I have resolved the issue.

Thanks and Regard's
Harish Patil
Go to Top of Page
   

- Advertisement -