Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2002
    Posts
    8

    Question Unanswered: Convert int to varchar with a specific format

    Hello!

    I would like to convert a int to a varchar with a specific format.
    For exemple:
    - 67 result in the varchar 0067
    - 125 result in the varchar 0125
    - 2345 result in the varchar 2345

    If anyone knows a easy way to do this without using cases I would appreciate.

    Thanks.

    Regards,
    Fernando

  2. #2
    Join Date
    Jan 2004
    Posts
    51
    Try following
    declare @x int
    select @x=22
    select right("0000" + convert(varchar(4),@x),4)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •