how to append 00 infornt of accountnumber

  • my query is in this sturcture

    declare @number numeric(10,0)

    set @number =(select distinct Number from tablename where conditions)

    select @number

    how to appent 00 while displaying number

  • try a shot

    declare @number varchar(10)

    set @number =(select distinct Number from tablename where conditions)

    select '00'+ @number

  • This is not easy for a numeric value, because you have to code '00'+@number everywhere in your code (see post of Nary). Better to convert to a string.

    declare @number char(10)

    set @number = '00' + CAST((select distinct Number from tablename where conditions) AS Char)

    select @number

    Now you only code '00' + @number once and you can just use @number on all other places in your code.

    ** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply