使用 t-sql 更新单行 [英] Update a single row with t-sql
本文介绍了使用 t-sql 更新单行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想更新我的日期库中的一行.问题是,由于我的错误,我有两行相同的数据.如何仅在一行上运行更新?
解决方案
通常表有一个唯一的 ID.您应该对此进行过滤.
例如
更新你的表SET YourColumnToUpdate = 'your_value'WHERE YourUniqueColumn = @Id
如果您的表没有唯一 ID,请考虑添加一个:带有 Primary Key
和 Identity
的 integer
列.>
I want to update a row in my date base. The problem is, through a mistake on my part, I have two identical rows of data. How do I run the update on just one row?
解决方案
Often tables have a unique ID. And you should filter on that.
For example,
UPDATE YourTable
SET YourColumnToUpdate = 'your_value'
WHERE YourUniqueColumn = @Id
If your table does not have a unique ID, consider adding one: an integer
column with a Primary Key
and Identity
.
这篇关于使用 t-sql 更新单行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文