本文介绍了sql更新问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,先生,
以下SQL查询是否有任何问题??
Hi Sir,
Is there any Prob with the Below SQL Query.?
DECLARE @Status varchar;
DeCLARE @Office_Status varchar;
Set @Status = 'Viewed';
Set @Office_Status= (Select Office_Status From tbl_Office
Where Master_ID = 1);
if (@Status = 'Viewed' AND @Office_Status= 'Finished')
BEGIN
Update tbl_Office Set Office_Status = @Status
Where Master_ID = 1
END
当前的"Office_Status"为"Finished",但尚未更新.请帮帮我.
谢谢,
Dileep
The Current "Office_Status" is "Finished" , But it is not yet Updating. Please Help me.
Thanks,
Dileep
推荐答案
UPDATE tbl_Office
SET Office_Status = 'Viewed'
WHERE Master_ID = 1
AND Office_Status = 'Finished';
SELECT @Status AS Status, @Office_Status AS Office_Status
if (@Status = ''Viewed'' AND @Office_Status= ''Finished'')
无论如何,您要在查询块中设置@status.那为什么需要它呢?
只需将其设置为
Anyhow you are setting @status inside the query block. So why is it required?
just make it as
if( @Office_Status= ''Finished'')
这篇关于sql更新问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!