Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 update = Add 1

Author  Topic 

Sprinjee
Starting Member

42 Posts

Posted - 2006-05-30 : 16:11:06
This is probably a longshot, and against any sql practice...but anyway...

is it possblie to perform an update query which add 1 to an interger column

For instance:

current content of table:

Col1 Col2
Score 4

update table set col2 = + 1 where col1 = score

The result I would wish for is:

Col1 Col2
Score 5

(without selecting the currect content as a variable first)

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-05-30 : 16:15:10
update table
set col2 = col2 + 1
where col1 = 'score'

Tara Kizer
aka tduggan
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-05-30 : 16:16:11
UPDATE Table
SET Col2 = Col2 + 1
WHERE Col1 = 'Score'
Go to Top of Page

Sprinjee
Starting Member

42 Posts

Posted - 2006-05-30 : 16:18:00
Bit embarrassed ...sometimes solutions are simple

Works like a charm thx for the quick reply
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-05-31 : 01:20:29
quote:
Originally posted by Sprinjee

Bit embarrassed ...sometimes solutions are simple



Its happense somtime simple stuff doenst click fast..

If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-31 : 02:36:54
>>set col2 = + 1

Dont try client side coding in SQL

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -