SQL server field size issue

rkrause

Registered User.
Local time
Yesterday, 18:05
Joined
Sep 7, 2007
Messages
343
I have a field in my query that are like this
1
2
3
4
5
6
7
8
9
10
11
ect, but i want to know if there is away to make a field 2 digits so that my sigle digits will be 01,02,03, ect and then 10 11, 12 will stay the same?
 
Here is some sample code that would do that, you will need a text based field


DECLARE @num varchar(10)

SET @num= '1'

INSERT INTO table_1
(id)

SELECT CASE WHEN LEN(@num) = 1 THEN '0' + @num ELSE @num END
 
Last edited:

Users who are viewing this thread

Back
Top Bottom