you can not access the local temp table outside the scope of dynamic sql , you need to create the global temp tables... Read on Bol for more details.. Local Temp Table Example DECLARE @SQL NVARCHAR(2000)SET @SQL = N'CREATE TABLE #TEST_CREATE1 'SET @SQL = @SQL + ' ( ID INT, NAME VARCHAR(100))'SET @SQL = @SQL + ' Select * from #TEST_CREATE1 'EXEC (@SQL)
Global Temp Table Example DECLARE @SQL NVARCHAR(2000)SET @SQL = N'CREATE TABLE ##TEST_CREATE1 'SET @SQL = @SQL + ' ( ID INT, NAME VARCHAR(100))'EXEC (@SQL)Select * From ##Test_Create1Drop Table ##Test_Create1
If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them.