March 11, 2010 at 5:23 am
I need to have a Leading Zero's in an Integer column. Is there a way to do it?
i.e. I require 00020 to be stored in table as 00020 and not as 20
March 11, 2010 at 5:41 am
Then it's a string, not an integer.
Store it as an integer, and handle how you display that later. Perhaps as a computed column?
Rob Farley
LobsterPot Solutions & Adelaide SQL Server User Group
Company: http://www.lobsterpot.com.au
Blog: http://blogs.lobsterpot.com.au
March 11, 2010 at 5:49 am
To illustrate Rob's point:
DECLARE @Sample
TABLE (
raw_data INTEGER NOT NULL,
fixed_length AS
RIGHT(100000 + raw_data, 5)
);
INSERT @Sample (raw_data) VALUES (20);
SELECT raw_data, fixed_length
FROM @Sample;
Output:
raw_data fixed_length
======== ============
20 00020
March 4, 2011 at 4:15 am
Thanks SQLKiwi, that was really helpful...
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply