1. Execute the stored procedure
exec p_employee_same '2017-07-26', '2017-07-26' prompt error, as shown
--- dbo.hr_employee [ID] as the primary key
Modify the exec statement as follows:
begin try
begin tran
exec p_employee_same '2017-07-26','2017-07-26'
commit tran
end try
begin catch
rollback tran
end catch
There is no problem in execution, because there is no transaction nesting and rollback in the alter stored procedure, and it is resolutely modified to:
ALTER proc [dbo].[p_employee_same](@begindate varchar(10),@enddate varchar(10))
as
begin
begin try
begin tran
insert into,,,,,,,,,,,,,,,,,,,,,,,,,,,
update ,,,,,,,,,,,,,,,,
commit tran
end try
begin catch
rollback tran
end catch
end
There is no error in the execution, but the value of insert into does not take effect, because there is a union all superposition insertion in insert into, ID: 342767 is repeated, excluded and then executed, the insert is completed.