SQL Server 2012在我更新之前检查我的SQL查询

[英]SQL Server 2012 CHECK MY SQL QUERY BEFORE I UPDATE


I have this update query but I do not want to run before I check what changes it will make.

我有这个更新查询,但我不想在检查它将做什么更改之前运行。

UPDATE tblControls_ContractSetpointProfile
SET CoolingOccupied = 76
FROM tblMEP_Sites
JOIN tblControls_ContractSetpoint ON tblControls_ContractSetpointProfile.ID = ContractSetpointID
WHERE ProjectID in (28, 47)

I though I just need to replace UPDATE WITH SELECT but that did not work. The answer to this question does not work, please do not change anything as I see SET CoolingOccupied = 76 is missing in the solution. I am not a database programmer but I have to do this because the person who is supposed to do this is absent. Thank you for understanding.

我虽然我只需要用SELECT替换UPDATE,但这不起作用。这个问题的答案不起作用,请不要改变任何东西,因为我看到解决方案中缺少SET CoolingOccupied = 76。我不是数据库程序员,但我必须这样做,因为应该这样做的人不在。谢谢你的理解。

1 个解决方案

#1


0  

To see what will be modified, run this query:

要查看将要修改的内容,请运行以下查询:

SELECT CoolingOccupied
FROM tblMEP_Sites
JOIN tblControls_ContractSetpoint ON tblControls_ContractSetpointProfile.ID = ContractSetpointID
WHERE ProjectID in (28, 47)

The rows returned by this will be the rows that will be updated by your query.

由此返回的行将是您的查询将更新的行。

When doing the update, you could also perform it within a transaction, that way you can verify the rows that it updates before deciding to commit or rollback if it isn't what you expect.

执行更新时,您还可以在事务中执行此操作,这样您就可以在决定提交或回滚之前验证它更新的行(如果它不是您所期望的)。

智能推荐

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2013/07/02/4bf5feb52a735da8b64b69d4d3f90ed1.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告