What happens is that I want to send a table-like parameter to a stored procedure that is called inside the body of another stored procedure.
The second process takes a little more time so I wanted to know if the first one waits for the second one.
What happens is that I want to send a table-like parameter to a stored procedure that is called inside the body of another stored procedure.
The second process takes a little more time so I wanted to know if the first one waits for the second one.
Indeed the first stored procedure expects to finish the execution of the second.
In general, in a SQL database, the execution of a program is sequential. There are engines (and SQL Server is one of them) that execute many operations in parallel, for example, to solve a query, but it is guaranteed that a TSQL block will be executed sequentially, that is, an instruction will be executed until it has finished of executing the previous one.
It's easy to check it by creating two stored procedures how are you:
create procedure Segundo as
begin
print convert(varchar, getdate(), 121) + ' Inicia el segundo';
WAITFOR DELAY '00:00:05'; //una espera artificial...
print convert(varchar, getdate(), 121) + ' Termina el segundo';
end;
go
create procedure Primero as
begin
print convert(varchar, getdate(), 121) + ' Inicia el primero';
exec Segundo;
print convert(varchar, getdate(), 121) + ' Termina el primero';
end;
go
The call to First
exec Primero;
Produce an output like this:
2016-12-01 09:36:49.640 Inicia el primero
2016-12-01 09:36:49.640 Inicia el segundo
2016-12-01 09:36:54.647 Termina el segundo
2016-12-01 09:36:54.647 Termina el primero