Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2007-07-20
3
Medium Priority
?
1,873 Views
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?

regards
0
Comment
Question by:Dnx_7
  • 2
3 Comments
 
LVL 75

Expert Comment

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

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 19529824
SELECT RIGHT (replicate('0',10)+'123', 10)
0
 
LVL 2

Author Comment

by:Dnx_7
ID: 19530197
thank you, very nice solution!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Suggested Courses

580 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