0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【C#】ASP.NET Coreで行ロックする方法

Posted at

UPDATE文で行ロックする際に方法について下記に記載します。
例えば、employeeテーブルの特定の行を更新したい場合は下記のように記載します。

update.sql
UPDATE <テーブル名> WITH (ROWLOCK) 
SET name = XXX
WHERE
 id = 1

のような形で記載いします。

備忘録でサンプルを追記しておきます。

sample.sql
UPDATE [test].[dbo].[employee] WITH (ROWLOCK)
SET
department = @department,
section = @section,
jobclass = @jobclass,
name = @name,
ipaddress = @ipaddress,
sex = @sex,
ipaddressalocation = @ipaddressalocation
WHERE
employeeId = @employeeId
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?