How to fill zero in the left to get a varchar(10)?

Posted on 2007-07-20
Last Modified: 2009-07-29
Hi experts,

i would like to fill a varchar(10) with "0"

eg i have this varchar : "123"

so i would like to create such a string : "0000000123"

can you help me?

Question by:Dnx_7
    LVL 75

    Expert Comment

    by:Aneesh Retnakaran
    SELECT RIGHT ('0000000000'+@urVriable, 10)
    LVL 75

    Accepted Solution

    SELECT RIGHT (replicate('0',10)+'123', 10)
    LVL 2

    Author Comment

    thank you, very nice solution!

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
    Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
    Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
    Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now