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.
| Author |
Topic |
|
jamonakes
Starting Member
18 Posts |
Posted - 2005-06-20 : 07:58:36
|
| I want to be updating the value of a certain column cell by incrementing the value by 1 everytime a certain condition is fulfilled. This is my SQL statement:INSERT INTO tblArtists(tblArtists.artVote) Values(SELECT MAX(IsNull(tblArtists.artVote,0) + 1) AS artVote FROM tblArtists WHERE tblArtists.artLinkID = 'a' AND tblArtists.artGenreID =25)When I do this I get the following error message:Server: Msg 1046, Level 15, State 1, Line 1Subqueries are not allowed in this context. Only scalar expressions are allowed.The example above is on INSERT. I would like someone to help on this and also, more importantly, on an update for the similar example above. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-06-20 : 08:02:49
|
Try thisINSERT INTO tblArtists(tblArtists.artVote) SELECT MAX(IsNull(tblArtists.artVote,0) + 1) AS artVote FROM tblArtists WHERE tblArtists.artLinkID = 'a' AND tblArtists.artGenreID =25 MadhivananFailing to plan is Planning to fail |
 |
|
|
jamonakes
Starting Member
18 Posts |
Posted - 2005-06-20 : 09:12:28
|
| Thanks a million, it works. I even got to tweak the code for the update statement. Thanks once again. |
 |
|
|
|
|
|