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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Adding leading zero's to make 12 with CAST

Author  Topic 

edusqluser
Starting Member

15 Posts

Posted - 2009-09-02 : 17:12:47
I am using the following:
'QUOTE PRICE' = CAST(
CASE
WHEN o.QuotePrice = NULL THEN 0
ELSE CASE ISNULL(omnd.PercentageOfOrder,0)
WHEN 0 THEN o.QuotePrice
ELSE o.QuotePrice * (ISNULL(omnd.PercentageOfOrder,0)/100)
END
END
AS DECIMAL(14,2))


What function can I use in conjunction with this to obtain the leading zeros of 12?

THX, EDUSQLUSER

robvolk
Most Valuable Yak

15732 Posts

Posted - 2009-09-02 : 17:16:18
[code]REPLACE(STR(
CASE WHEN o.QuotePrice = NULL THEN 0
ELSE CASE ISNULL(omnd.PercentageOfOrder,0)
WHEN 0 THEN o.QuotePrice
ELSE o.QuotePrice * (ISNULL(omnd.PercentageOfOrder,0)/100) END
END,
14,2),
' ', '0') AS [QUOTE PRICE][/code]
Go to Top of Page

edusqluser
Starting Member

15 Posts

Posted - 2009-09-02 : 17:28:45
Thanks. That did it...

THX, EDUSQLUSER
Go to Top of Page
   

- Advertisement -