Link to home
Start Free TrialLog in
Avatar of yurrea
yurrea

asked on

Remove leading/trailing zeroes

How do I remove leading and trailing zeroes in a column (string/char(100))?
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

if you mean blanks, use the RTRim and LTrim function:
UPDATE YourTable
SET YourCol = LTrim(RTrim(YourTable))

If the column is CHAR(100), there will always remain the trailing spaces, as SQL Server keeps them. This can only be changed by changing the data type from CHAR to VARCHAR.

if you want to remove zeroes (0), i will post other script...
Avatar of yurrea
yurrea

ASKER

could you post the script to remove zeroes ...
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yurrea

ASKER

THANKS
Glad i could help