Marcus Aurelius
asked on
Most Optimized Way to Update a Table using STORED PROCEDURE?
Experts,
Which is the most optimized way to update a table using a STORED PROCEDURE?
Like this?:
----------
update a
set col1 = b.col1
from table1 a
inner join --SUBQUERY TABLE
(select id, desc
from table3) b on a.id = b.id
OR like this:
-------------
create table #Temp1 (id int, desc varchar(25))
insert into #Temp1
(select id, desc
from table3)
update a
set col1 = b.col1
from table1 a
inner join #Temp1 b on a.id = b.id
Which is the most optimized way to update a table using a STORED PROCEDURE?
Like this?:
----------
update a
set col1 = b.col1
from table1 a
inner join --SUBQUERY TABLE
(select id, desc
from table3) b on a.id = b.id
OR like this:
-------------
create table #Temp1 (id int, desc varchar(25))
insert into #Temp1
(select id, desc
from table3)
update a
set col1 = b.col1
from table1 a
inner join #Temp1 b on a.id = b.id
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for all the input
ASKER
I'm seeking more of a "generally speaking" type of feedback.
Is it generally speaking better to have the stored procedure process the update using a "SUB-QUERY" as an inline table...
OR
Use the query to load a TEMP TABLE and use the TEMP TABLE to link to in an UPDATE STATEMENT.....?