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)
 incrementing value with 1 query

Author  Topic 

obewankanoochie
Starting Member

24 Posts

Posted - 2003-11-07 : 17:40:22
Is there a way to increment a value without first doing a SELECT query, then adding 1 to it, then doing an UPDATE query?

I'm running SQL 7 with ASP.

Thanks.



jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-11-07 : 17:44:44
UPDATE table
SET col1 = col1 + 1
WHERE <some condition>

??

All one statement, no SELECT first.

- Jeff
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-11-07 : 17:44:52
UPDATE Table1
SET Column1 = Column1 + 1

Tara
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-11-07 : 17:45:12
Got sniped!



Tara
Go to Top of Page

Stoad
Freaky Yak Linguist

1983 Posts

Posted - 2003-11-07 : 20:45:59
New progressive approach from East Europe:

UPDATE Table2
SET Column2 = Column2 + 1
WHERE Column2 Is Not Null
Go to Top of Page
   

- Advertisement -