how to remove '0' from left of the column in sql server 2005

colum type is varchar and want to remove '0' only from left.
sample data
000007
000008
000009
000010

output should be
7
8
9
10



easy_lifeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kevin CrossChief Technology OfficerCommented:
One easy way if these are numbers is to:

CAST(columnname AS INT)

You may want BIGINT depending on the scale of the field, but hopefully you get the idea.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Aneesh RetnakaranDatabase AdministratorCommented:
SELECT CAST (urColumn as INT)  newname
from urTable
0
justin-clarkeCommented:
SELECT (CAST Col1 AS int) AS Col1

Then converts it to an INT therefore removing the leading zeros
0
Scott PletcherSenior DBACommented:
SELECT SUBSTRING(columnName, PATINDEX('%[^0]%', columnName), DATALENGTH(columnName))


For example:

SELECT SUBSTRING(columnName, PATINDEX('%[^0]%', columnName), DATALENGTH(columnName))
FROM (
    select '000007' as columnname union all select
'000008' union all select
'000009' union all select
'000010' union all select
'00010010'
) as testdata
0
easy_lifeAuthor Commented:
Thanks for your quick response
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.