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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-04-22 : 21:56:35
|
Averno writes "I need to manage the number of rows affected by a query. If I run this script on my database: SELECT COUNT(*) FROM TABLE_NAME WHERE TABLE_NAME.FLAG = 'I' AND NOT EXISTS ( SELECT * FROM ERR_TABLE_NAME WHERE ERR_TABLE_NAME.FIELD_1 = TABLE_NAME.FIELD_1 AND ERR_TABLE_NAME.FIELD_2 = TABLE_NAME.FIELD_2 ) the query analyzer gives me back the number of lines affected: ----------- 4,00
(1 row(s) affected)
I need to manage this amount (4,00), so I applied this modification:
DECLARE @NUM_ROWS INT
SET @NUM_ROWS = (SELECT COUNT(*) FROM TABLE_NAME WHERE TABLE_NAME.FLAG = 'I' AND NOT EXISTS ( SELECT * FROM ERR_TABLE_NAME WHERE ERR_TABLE_NAME.FIELD_1 = TABLE_NAME.FIELD_1 AND ERR_TABLE_NAME.FIELD_2 = TABLE_NAME.FIELD_2 ) )
but it doesn't work!! the SRV returns me this: Server: Msg 107, Level 16, State 3, Line 3 The column prefix 'TABLE_NAME' does not match with a table name or alias name used in the query.
Do you know another way to store the number of rows affected?" |
|
|
|
|
|