Very simply in SQL Server T-SQL parlance, how do you conver the number 9 to the string N'00009'?
You can try
SELECT RIGHT('00000' + CAST(number AS NVARCHAR), 5)
The result will be a string, not a number type.
If you're on SQL Server 2012 or later, you can also use the FORMAT function:
SELECT FORMAT(1, '00000') AS PaddedNumber
It nicely formats all kinds of stuff ...
You can use this:
SELECT REPLICATE('0',5-LEN('9'))+'9'
The result is string
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With