Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

remove leading zeroes and keep spaces and number

Status
Not open for further replies.
Joined
Jun 27, 2001
Messages
837
Location
US
I have a char(12) field that was loaded like '000000000101' I need to change the data to be ' 101'. Is there a way to do this and preserve the number and keep the leading spaces?
Thanks
 

There are several ways to do this in SQL . This may be the simplest. Simply converet the column to integer and back to a 12 character string.

Select
col1,
str(cast(Col1 as int),12,0) As NewCol1
from MyTable
Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top