I have a dynamic sql in stored procedure like
@sql = 'SELECT a,
b,
c d
FROM table t
LEFT JOIN table2 t2
ON t.id = t2.id '
and then inserting into a table variable
Insert into @tblCustomer
EXECUTE sp_executesql @sql
The insert statement is taking long time to execute. Is there any way i can improve it?
I am using SQL Server 2008
Thanks