c# - why we use temporary tables in sql server in place of normal table in stored procedure -
when use temporary table gets created in database tempdb performance overhead. if create normal table in stored procedure in place of temp table created in own database.
so question why use temp tables in procedure?
is due scope of tables?
we use temp tables1 want store set of rows , work them not want interfere other instance of same piece of code, running on different connection.
if worked permanent tables, we'd have work prevent interference (such filtering on @@spid
) or have restrict our code being executed single connection @ time.
we benefit automatic clean when temp table falls out of scope.
1or table variables. they're same, different scoping rules.
Comments
Post a Comment