SQL Server Automatic update to row number after deletion of row

new9mtju  于 2023-03-11  发布在  其他
关注(0)|答案(1)|浏览(173)

I have a table in SQL Server Express 2019 from which I read data by executing basic queries from my SCADA software. How can I create a column in the table containing a row number such that when I delete a row, all values in the column are automatically recalculated? My SCADA software can only execute simple, one-line queries. Is a computed column the answer? I started with an Identity column, but it does not update when a row is deleted. Thank you.

elcex8rz

elcex8rz1#

It's normally process when you define identity column. Why you want automatically recalculation ? I think that it's not best practice but you can do it with trigger. The trigger will degrade your database performance.

相关问题