简体   繁体   中英

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.

在此处输入图片说明

now, I am trying to update 2 records at the same time,that is one property has two different owners.

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?

You must have a unique ID or at least a different value in your rows. When you update the table with this WHERE clause: where PropertyId = '59' , each time, it updates all the rows that have propertyId of 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. or maybe, this answer helps you:

SQL Server how to update only one row in database?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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