Tengo la siguiente consulta:
DECLARE @QUERY NVARCHAR(400)='
INSERT INTO #AA(idCampoID)
SELECT ID FROM BB
'
DECLARE @CREATETABLE NVARCHAR(400)='
IF OBJECT_ID(''tempdb..#AA'') IS NOT NULL DROP TABLE #AA
CREATE TABLE #AA
(
ID INT
)
'
EXEC sp_ExecuteSql @CREATETABLE
EXEC sp_ExecuteSql @QUERY
EXEC sp_ExecuteSql @CREATETABLE EXEC sp_ExecuteSql @CREATETABLE
Necesito obtener la tabla #AA#AA
con un SELECT.