If it's T-SQL try using a BEGIN
statement instead of then
IF 1 > 0
BEGIN
UPDATE TABLE_A
SET COLUMN_1 =299999
WHERE COLUMN_2 ='2014-01-03' and COLUMN_3=0
END
题
So right now I have a simple SQL store procedure which I can call to update one of the tables in my database. Within the store procedure, I have an If conditional statement:
IF 1 > 0 THEN
UPDATE TABLE_A
SET COLUMN_1 =299999
WHERE COLUMN_2 ='2014-01-03' and COLUMN_3=0;
I'm pretty sure the update clause has no problem because when I run it separately, it updates the table fine. I can see the value being updated in the table.
However, right when I put it after the IF
statement(like the code above), the update fails(returns me no rows affected).
I'm pretty sure the IF statement is correct as well(right now I put it as 1>0 just for testing).
If I put an insert statement after the IF, it works fine too. A new row is being inserted into the table. This is so weird. Any help ?
解决方案
If it's T-SQL try using a BEGIN
statement instead of then
IF 1 > 0
BEGIN
UPDATE TABLE_A
SET COLUMN_1 =299999
WHERE COLUMN_2 ='2014-01-03' and COLUMN_3=0
END
其他提示
try this
UPDATE TABLE_A
SET COLUMN_1 =299999
WHERE COLUMN_2 ='2014-01-03'
AND COLUMN_3=0
AND 1 > 0 ; <------- put it in where clause