Results 1 to 10 of 10
  1. #1
    Join Date
    Sep 2006
    Posts
    57

    Unanswered: Increment a value

    Is there an easy and fast way to increment a value by 1 in a database? For example if a value is 106 I will need to make it 107. Is there a fast way to do this?

  2. #2
    Join Date
    Jan 2006
    Location
    USA
    Posts
    115
    There are different ways, but main concerning thing is why you want this..?
    Rajesh Patel

    Everybody says - mistake is the first step of success, but it's not true. The correction of the mistake is the first step of success.

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    UPDATE yourtable SET thecolumn = thecolumn + 1 WHERE pkey = 937
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    Sep 2006
    Posts
    57
    my webapplication is counting the number of hits a certain item has been looked at by unique visitors. I thought it might be faster to let sql server do this work instead of my application. For example, When someone looks at a pair of binoculars the hit count and the hit count may be at 327. I must update this count to 328. Is it possible to make the sql server do this work?

  5. #5
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    r937 has given you the command that will make "SQL Server do this work"...

  6. #6
    Join Date
    Sep 2006
    Posts
    57
    OK..cool got it

    I wish I could give r937 and yourself some kind of thanks for your responses on this forum. As a suggestion you guys need some kind of thanks script. That post really helped me out and i just wanted to say thanks for it.

  7. #7
    Join Date
    Nov 2005
    Location
    San Francisco, CA
    Posts
    506
    Quote Originally Posted by Luke101
    OK..cool got it

    I wish I could give r937 and yourself some kind of thanks for your responses on this forum. As a suggestion you guys need some kind of thanks script. That post really helped me out and i just wanted to say thanks for it.
    LOL, any help for the script...waiting for replies
    Success is the ability to go from one failure to another with no loss of enthusiasm.
    - Sir Winston Churchill
    Joydeep

  8. #8
    Join Date
    Nov 2005
    Location
    San Francisco, CA
    Posts
    506
    First one from me...


    SELECT ' to ', FROM post
    WHERE LIKE ' %'
    Success is the ability to go from one failure to another with no loss of enthusiasm.
    - Sir Winston Churchill
    Joydeep

  9. #9
    Join Date
    Sep 2006
    Posts
    57

  10. #10
    Join Date
    Nov 2005
    Location
    San Francisco, CA
    Posts
    506
    Quote Originally Posted by Luke101
    BTW mine was TSQL thank version ...
    Last edited by rudra; 09-30-06 at 16:12.
    Success is the ability to go from one failure to another with no loss of enthusiasm.
    - Sir Winston Churchill
    Joydeep

Posting Permissions

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