Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7973037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:00:04+00:00 2026-06-04T08:00:04+00:00

I have a stored procedure. I pass in 1 variable, called @p_FR , which

  • 0

I have a stored procedure. I pass in 1 variable, called @p_FR, which is a char(6). However, the passed value is not always 6 characters long. Sometimes the value is only 4 or 5 characters long. I need to make sure that the string is always 6 characters long. For example, if @p_FR is 8534, then I need to add 2 leading 0’s to @p_FR, so it would be 008534.

I tried doing

set @fr = right('000000', @p_FR, 6)

@fr is a varchar(6)

but when @p_FR is 8534, @fr is still 8534. I need it to be 008534.

I also set the following block of code in a fresh query, and I still got 8534.

declare @p_FR as char(6),
    @fr as varchar(6)
set @p_FR = '8534'
set @fr = right('000000' + @p_FR, 6) 
select @fr
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:00:06+00:00Added an answer on June 4, 2026 at 8:00 am

    Use rtrim to remove blanks:

    declare @p_FR as char(6),
        @fr as varchar(6)
    set @p_FR = '8534'
    set @fr = right('000000' + rtrim(@p_FR), 6) 
    select @fr
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Stored Procedure (SP) in which I pass in one value. In
I have sql stored procedure which pass and return some values: CREATE PROCEDURE [dbo].[GetMoney]
I have stored procedure which I will execute its result and pass it into
In my stored procedure I have to pass a table and column name which
I have a stored procedure which takes an XML parameter and inserts the data
I have a stored procedure which selects a single field from a single row
I have a stored procedure that returns a dynamic query, e,g if i pass
I have a stored procedure that I would like to pass a string to,
I have a Stored procedure, in which I have to insert 3 strings into
SQL Server 2005. I have a stored procedure which accepts a few parameters that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.