Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Community Discussions (All other subjects)
 Right() function And + op in T-SQL problem..
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

GoodMorningSky
Junior Member

122 Posts

Posted - 07 October 2003 :  21:29:50  Show Profile

select Right('000' + Convert(char(3), FS.STORE_ID), 4) as stid
FROM STORES as FS

STORES table contains STORE_ID as char(3). But, I need it as char(4)
with preceeding '0's.
So,
I expect the above query returns all stid with '####' 4 digit char.
However it returns 3 or 4 digit.

I tried this too.

select Right('000' + Convert(char(3), FS.STORE_ID), 4) as st
FROM STORES as FS

But, same problem..

I used (case when Len(fs.store_id) = 2 then '00' + fs.store_id
when Len(fs.store_id) = 3 then '0' + fs.store_id
ELSE fs.store_id
End) instead of rigth(). it retruns as I expected..

What is problem with Right function in T-SQL?

Thank you..

Software Engineer.
MCSD.NET, SCWCD
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.25 seconds. Powered By: Snitz Forums 2000 Version 3.4.07