I am runnig query select count(*) from A
I like to display the count in following format. For ex.
If the count is 45 then it should display 000045
If the count is 145 then it should display 000145
If the count is 5 then it should display 000005
If the count is 0 then it should display 000000
Let know how is this possible.
Thanks in advance,
PeteCREATE TABLE #ValueTable (value INT)
INSERT INTO #ValueTable
SELECT 1
UNION ALL
SELECT 500
UNION ALL
SELECT 4000
UNION ALL
SELECT 50000
UNION ALL
SELECT 00000
--Use RIGHT to pad the value
SELECT value, RIGHT('000000' + CONVERT(VARCHAR,value),6) AS
FormattedValue
FROM #ValueTable
drop table #ValueTable
http://sqlservercode.blogspot.com/
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment