Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2007
    Posts
    4

    Unanswered: using update to increment a varchar by 1

    I am trying to figure out the sql that can give me the following.

    Increment a value of say, 001, by 1 for a field that is a varchar.

    Im thinking something like this but its incorrect.

    update table set CAST(varchar_field AS INTEGER)=001 + 1 where ....

    thanks.

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    You want something like: update mytable set varchar_col = char(integer(varchar_col) + 1) where ...

    Be warned that if the column has non-numeric data it will fail.

    Andy

  3. #3
    Join Date
    Jan 2007
    Posts
    4
    sounds good, ill try that out.

    thanks !

Posting Permissions

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