I have a question here regarding filling temp table from stored procedures in SQL Server. When we already have table schema of a table we can fill it from stored procedure as:
Create #tempTable (Id int, Value varchar(50))
Insert into #tempTable
exec GetValues
Where GetValues returns the same schema as declared for #tempTable.
Here is another case when we fill a temp table from another table
Select colA,colB into #tempTableA from SomeTable
Here we don't need to know the schema of #tempTableA, it will be same as based on selected columns from table SomeTable.
My question is: how can we fill a #temptable without knowing it's schema, from a stored procedure? As we do when filling a temp table from some other table.
SELECT * INTO #tmpTable FROM OPENQUERY(YOURSERVERNAME, 'EXEC test.dbo.prc_test 1');
Insert results of a stored procedure into a temporary table
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With