sql - cascading copy with merge statement causing lock issues -
sql - cascading copy with merge statement causing lock issues -
sql server 2012 (sp1) 64gb ram using 50gb max server memory sp_configure 'locks' = 0 trace flags 1211 & 1224 off using read_committed set lock_timeout 0
while using merge
error:
the instance of sql server database engine cannot obtain lock resource @ time. rerun statement when there fewer active users. inquire database administrator check lock , memory configuration instance, or check long-running transactions.
too many developers experiencing ongoing problems merge, how else can efficiently cascading re-create of rows , related rows parent/child tables. e.g. tablea has many tableb rows , tablec has many tabled rows etc...
merge
useful when creating new identity values, while on same row keeping old identity info next table insert, there alternatives?
using single table insert output
command, cannot old , new id @ same time
insert tablea output inserted.[id],inserted.[col1],inserted.[col2],inserted.col3, #tmptable
what best options available in sql server?
i had revisit code quite create changes , did was: code
(1) create table #tmptable ([oldid] [bigint] ,[newid] [bigint] ), (2) add together oldid permanent column main table, same pk row (3) insert [dbo].[main table] output inserted.[oldid],inserted.[newid] #tmptable select oldid , column1, column2 ... code
- way info inserted new id , old id come on same row, i'm surprised msft doesn't have command in sql yet merge terribly slow!
sql sql-server database tsql merge
Comments
Post a Comment