Yosiasz: Actually, it's an old VB6 application which hasn't been converted yet. Connection cursor is client-side. But would that make a difference in how the command is executed by the provider?
Ah, but good stories they must be...! As long a MS supports COM, the larger applications are on the back-burner. Why do today what you can do tomorrow, right?
So anyway, this is what changed. They originally coded this:
cn1.Execute "Insert Into DB1.DBO.Table1 (a,b) Values (1,1) "
cn1.Execute "Insert Into DB1.DBO.Table1 (a,b) Values (2,2) "
cn2.Execute "Insert Into DB2.DBO.Table2 (c,d) Values (1,1) "
cn2.Execute "Insert Into DB2.DBO.Table2 (c,d) Values (2,2) "
and it was changed to:
cn1.Execute "Insert Into DB1.DBO.Table1 (a,b) Values (1,1) " &
"Insert Into DB1.DBO.Table1 (a,b) Values (2,2) " &
"Insert Into DB2.DBO.Table2 (c,d) Values (1,1) " &
"Insert Into DB2.DBO.Table2 (c,d) Values (2,2) "
Given that this bothers the server 4 times, the 4 execs were simply grouped into 1. In principle, it shouldn't make any difference w.r.t. the expected result.
Ya, actually, that would be a very reasonable thing to do in order to remove a variable in the diagnostic process. Then, if the problem persists, we know that it's not computer-related or cursor-related. I normally never give any thought to stored procs unless it's worth pre-compiling a time-consuming query. That's why it's so great to have someone else ring in with a fresh mindset.
Thank you so much for your contribution, it was really appreciated!!!
CREATE TYPE [dbo].[budgetresourcesType] AS TABLE(
[budgetid] [int] NOT NULL,
[salarygraderoleid] [int] NOT NULL
)
then use that type in your stored procedure
ALTER proc [dbo].[budgetresources_iudp]
(
@currentuser varchar(50),
@tvp budgetresourcesType readonly
)
as
/*
windchaser 9/3/2020 created
*/
begin
INSERT INTO [dbo].budgetresources
(budgetid
,salarygraderoleid
,[createddate]
,[createdby])
select budgetid,
salarygraderoleid,
GETDATE(),
@currentuser
from @tvp
end
GO