Professional Web Applications Themes

Padding 0 suffix to n - Microsoft SQL / MS SQL Server

One option: DECLARE month INT SET month = 2 SELECT RIGHT( '00' + CAST( month AS VARCHAR(2) ) , 2 ) "Brian" <net> wrote in message news:085b01c35715$11ef96f0$gbl... We have data with numeric number month coming in from external source. We placed this data into month column. If the month is less than 0ctober, we will have 1 to 9 instead of leading 01 to 09 in the column. How can we change the column from 1 to 9 to 01 to 09 or making the data become 01 to 09 before inserting them into the column? The column definition is ...

  1. #1

    Default Re: Padding 0 suffix to n

    One option:

    DECLARE month INT
    SET month = 2
    SELECT RIGHT( '00' + CAST( month AS VARCHAR(2) ) , 2 )



    "Brian" <net> wrote in message news:085b01c35715$11ef96f0$gbl...
    We have data with numeric number month coming in from
    external source. We placed this data into month column.
    If the month is less than 0ctober, we will have 1 to 9
    instead of leading 01 to 09 in the column. How can we
    change the column from 1 to 9 to 01 to 09 or making the
    data become 01 to 09 before inserting them into the
    column? The column definition is nvarchar.

    Thanks.
    Brian

    Damien Guest

  2. #2

    Default Re: Padding 0 suffix to n



    It does not help. The result is still showing 1 to 9.

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Brian Guest

  3. #3

    Default Re: Padding 0 suffix to n

    here is one more example

    create table MyTable (Monthcol nvarchar(2))

    insert MyTable values(1)
    insert MyTable values(2)
    insert MyTable values(3)
    insert MyTable values(4)
    insert MyTable values(5)
    insert MyTable values(6)
    insert MyTable values(7)
    insert MyTable values(8)
    insert MyTable values(9)

    Update Mytable
    set Monthcol = right('00'+Monthcol,2)

    select Monthcol from MyTable

    Results

    Monthcol
    --------
    01
    02
    03
    04
    05
    06
    07
    08
    09

    (9 row(s) affected)

    Pls provide your table definition , sample data and the query that you are
    using to help us in understanding why this doesnot work for you.


    HTH,
    Srinivas Sampangi


    "Brian Ho" <net> wrote in message
    news:#phx.gbl... 


    sampangi Guest

Similar Threads

  1. dropping the suffix
    By wjlevin in forum Macromedia Exchange Dreamweaver Extensions
    Replies: 1
    Last Post: June 26th, 08:51 PM
  2. Contribute 2 renames files with a .new suffix
    By sazaroo in forum Macromedia Contribute General Discussion
    Replies: 0
    Last Post: March 23rd, 01:57 PM
  3. How to replace the SoapIn and SoapOut suffix
    By alex in forum ASP.NET Web Services
    Replies: 3
    Last Post: December 20th, 07:03 PM
  4. Why dosn't Freehand end files with a suffix ?
    By gkkra in forum Macromedia Freehand
    Replies: 6
    Last Post: May 4th, 06:41 PM
  5. image suffix .pzp
    By Richard_Straw@adobeforums.com in forum Adobe Photoshop Elements
    Replies: 10
    Last Post: October 5th, 08:58 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139