简体   繁体   English

SQL Server:更新节点JS中的多行

[英]SQL Server :Update multiple rows in node JS

I am trying to update multiple rows from node js to sql server database with no unique column.我正在尝试将节点 js 中的多行更新到没有唯一列的 sql server 数据库。

在此处输入图片说明

now, I am trying to update 2 records at the same time,that is one property has two different owners.现在,我正在尝试同时更新 2 条记录,即一个房产有两个不同的所有者。

UPDATE tbl_PropertyOwnerShip SET  OwnerName = 'ross' , SinceFrom = '2012-12-12' where PropertyId = '59';
UPDATE tbl_PropertyOwnerShip SET  OwnerName = 'mike' , SinceFrom = '2012-12-12' where PropertyId = '59';

在此处输入图片说明

Can anyone help me to sequencially update rows in sql server to get desired output?任何人都可以帮助我按顺序更新 sql server 中的行以获得所需的输出吗?

You must have a unique ID or at least a different value in your rows.您的行中必须有一个唯一 ID 或至少有一个不同的值。 When you update the table with this WHERE clause: where PropertyId = '59' , each time, it updates all the rows that have propertyId of 59.当您使用以下 WHERE 子句更新表时: where PropertyId = '59' ,每次都会更新 propertyId 为 59 的所有行。

Maybe you need to add a new table, then add all the rows in this table to the new table beside an unique ID there.也许您需要添加一个新表,然后将这个表中的所有行添加到新表旁边的唯一 ID 中。 or maybe, this answer helps you:或者,这个答案可以帮助您:

SQL Server how to update only one row in database? SQL Server如何只更新数据库中的一行?

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

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