venu_ksheerasagaram (11/1/2009)
Hi All,Here i am having a doubt regarding the Dynamic Query. My requirement is How to store the Dynamic Query resultset into a TempTable? Could it possibel?
Because i need to fire a Search Query on the result set that was generated by the Dyamic query.
Thank you all,
Here is a possible way to do that:
CREATE TABLE #TempLocal (MyName sysname);
EXEC sp_executesql
N'INSERT INTO #TempLocal (MyName) SELECT [name] FROM sysobjects'; --dynamic sql query to execute
SELECT MyName FROM #TempLocal;
DROP TABLE #TempLocal;