SELECT RIGHT('000'+ISNULL(field,''),3)
NULL values will show as 000
If you have an Integar Value that you want to add leading zero's then:
SELECT RIGHT('000'+CAST(field AS VARCHAR(3)),3)
This blog is mostly a blog for me with hints to remember those little bits of code etc where ever I am. Please be aware of this when reading any of the posts as they are mainly reminders for me. When I get time I will try to flesh out those sections that are a little ambiguous.
SELECT RIGHT('000'+ISNULL(field,''),3)
SELECT RIGHT('000'+CAST(field AS VARCHAR(3)),3)
select field1,field2,field3, count(*)
from table_name
group by field1,field2,field3
having count(*) > 1