更新没有IDENTITY列的表 [英] Update table that does not have a IDENTITY column

查看:108
本文介绍了更新没有IDENTITY列的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个sql server数据库表,如下所示



I have a sql server database table whose is as below

CREATE TABLE UserNotifications
(
[Ref_NotificationType_ID] [int] NOT NULL, this is a foreign key column
[From_Employee_ID] [int] NOT NULL, this is a foreign key column
[To_Empoyee_ID] [int] NOT NULL, this is a foreign key column
[Ref_Identity_ID] [bigint] NOT NULL, this is a foreign key column
[Identity_Type] [smallint] NOT NULL,
[VersionNumber] [int] NOT NULL,
[Priority] [bit] NOT NULL,
[Created_DateTime] [datetime] NOT NULL,
[Created_By] [varchar](max) NOT NULL,
[Last_Updated_DateTime] [datetime] NULL,
[Last_Updated_By] [varchar](max) NULL,
[HasUserRead] [bit] NOT NULL,
[IsActive] [bit] NOT NULL,
[Flag] [bit] NOT NULL
)





如何在不影响其他匹配行的情况下更新上表中的特定列?< br $> b $ b

我尝试了什么:



我尝试更新记录使用created_datetime列



How do i update a specific column in this above table without affecting other matching rows?

What I have tried:

I tried updating a record by using the created_datetime column

推荐答案

即使基于多列,您也需要一种唯一标识行的方法



You need a way to uniquely identify the row even if it is based on multiple columns

update UserNotifications set field=value where
Ref_NotificationType_ID = 1
and From_Employee_ID = 100
and To_Empoyee_ID = 200
and ...


这篇关于更新没有IDENTITY列的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆