MC
https://www.sqlshack.com/when-to-use-temporary-tables-vs-table-variables/
Size: a a a
MC
MC
MC
ДС
begin transaction
go
create procedure t1
as
begin
create table #tab (i int)
insert into #tab values (1)
select i as proc_t1 from #tab
end
go
create procedure t2
as
begin
create table #tab (i nvarchar(10))
insert into #tab values (2)
select i proc_t2 from #tab
exec t1
end
go
create table #tab (i nvarchar(10))
insert into #tab values (0)
select i as i0 from #tab
go
exec t2
select i as i1 from #tab
rollback transaction
go
i0
----------
0
proc_t2
----------
2
proc_t1
-----------
1
i1
----------
0
MC
For example, if a stored procedure creates a temporary table with a named primary key constraint, the stored procedure cannot be executed simultaneously by multiple users.
create index UQ_table_758342 on...
MC
begin transaction
go
create procedure t1
as
begin
create table #tab (i int)
insert into #tab values (1)
select i as proc_t1 from #tab
end
go
create procedure t2
as
begin
create table #tab (i nvarchar(10))
insert into #tab values (2)
select i proc_t2 from #tab
exec t1
end
go
create table #tab (i nvarchar(10))
insert into #tab values (0)
select i as i0 from #tab
go
exec t2
select i as i1 from #tab
rollback transaction
go
i0
----------
0
proc_t2
----------
2
proc_t1
-----------
1
i1
----------
0
MC
create index UQ_table_758342 on...
create table #t (
id int identity,
constraint PK_t_id primary key (a)
)
а коротким способом create table #t (id int identity primary key)
Тогда снова можно запускать процедуры параллельно 😎К
ДС
create table #t (
id int identity,
constraint PK_t_id primary key (a)
)
а коротким способом create table #t (id int identity primary key)
Тогда снова можно запускать процедуры параллельно 😎ДС
AL
AL
AL
ДС
ДМ