SEDE Temp Table Tests (With DSQL)

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

--Works
EXEC('
  CREATE TABLE #Foo (ID int);
  INSERT INTO #Foo VALUES (14);
  SELECT * FROM #Foo;
  DROP TABLE #Foo;')
GO

--Works
CREATE TABLE #Foo (ID int)
INSERT INTO #Foo VALUES (15)
SELECT * FROM #Foo
DROP TABLE #Foo
GO

--Doesn't work, the isolation of the dynamic sql does not permit
--temp tables to persist through multiple `EXEC` statements
--EXEC('CREATE TABLE #Foo (ID int)')
--EXEC('INSERT INTO #Foo VALUES (16)')
--EXEC('SELECT * FROM #Foo')
--EXEC('DROP TABLE #Foo')
--GO

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results