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 |
|
swanagetown
Starting Member
19 Posts |
Posted - 2005-04-18 : 07:16:07
|
| Hi,I'm new to sql & Sp and struggling with a statemtent can anybody please help?Basically I've got a SELECT statement with an inner join which is getting data from 2 tables based on 3 parameters. At the same time as doing this I would like to increment a column in table3 to refect a search has been made.CREATE PROCEDURE dbo.procedure1(@IntID varchar, @value1 int, @value2 int, @value3 decimal(8,7))ASSELECT table1.col1, table1.col2, table1.col3, (CASE WHEN col4 = '0' THEN 'Cool' WHEN col4 = '1' THEN 'not Cool' END) AS col4, FROM ........... INNER JOIN .....WHERE ......UPDATE(CASE WHEN IntID = @IntID THEN searches + 1 END) AS table3.searchesFROM Table3GO |
|
|
swanagetown
Starting Member
19 Posts |
Posted - 2005-04-18 : 07:54:25
|
| Is this the best way?@IntID varch(10)UPDATE Table3SET nosearches = nosearches + 1WHERE (IntID = @IntID) |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2005-04-18 : 09:38:13
|
Looks OK to me.I'd be worried about something called @intID being a VARCHAR rather than an INT though ... Kristen |
 |
|
|
|
|
|