Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

Casting an Integer and prepending a 0

$
0
0

I have an integer value for month as a single digit. I want to cast it to a string an ensure that if it's less than 10 it will always have a 0 prepended to it. This what I am working on, but having trouble. Could you give advice? Thanks

DECLARE @month INT
SET @month = REPLACE( CAST(1 as VARCHAR(2)), ' ', '0')
SELECT @month AS month


Viewing all articles
Browse latest Browse all 8428

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>