I have something like:
DECLARE @tbl TABLE
(
name varchar(255),
type int
)
UPDATE c
SET c.name = t.name
FROM dbo.cars c
JOIN @tbl t ON t.type = c.type
I have a stored procedure that does something similar but it takes over 20 minutes with the table variable. It runs in less than 2 minutes if I change it from table variable to temp table. Why is this so?