简体   繁体   English

更新列SQL Server中的值

[英]Updating value in a column SQL Server

This should be a really easy question, but I wanted to make sure it was done right where I'm not a SQL guy. 这应该是一个非常简单的问题,但是我想确保在我不是SQL专家的情况下正确完成了操作。 We need to turn all of the patients with a security level of 1 to 2. All patients who are not at 1 are currently at 2. Thanks and sorry for asking such a simple question. 我们需要将所有安全级别从1更改为2的患者。所有非1的患者当前都处于2。感谢和抱歉提出这样一个简单的问题。 SQL Server 2005. SQL Server 2005。

select 

patient_id,
security_level

from patient
where security_level = '1'

在此处输入图片说明

SQLFIDDLE SQLFIDDLE

update patient set security_level = '2' 
where security_level = '1';

Above will update the entire patient table, and set the security level to 2 (where it initially was 1). 上面将更新entire患者表,并将安全级别设置为2(最初为1)。

A simple update should work. 一个简单的更新应该起作用。 Something like: 就像是:

UPDATE patient
SET sercurity_level='2'
WHERE security_level='1';

Edit: changed correct table name and added quotes 编辑:更改正确的表名称并添加引号

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM