Home >Database >Mysql Tutorial >How to Insert Stored Procedure Results into a Temporary Table Using OPENROWSET?
Using OpenRowSet to insert the storage process into the temporary table
The use of to insert the storage procedure into the temporary table may fail due to grammatical errors. The solution is to use the method.
First of all, you need
SELECT * INTO
OPENROWSET
After enabling, you can use the following code to insert the results of the storage procedure into the temporary table. No need to define the table structure in advance:
In this example, the storage procedure
<code class="language-sql">sp_configure 'Show Advanced Options', 1 GO RECONFIGURE GO sp_configure 'Ad Hoc Distributed Queries', 1 GO RECONFIGURE GO</code>return the data of the
table. By , the results of the storage procedure can be effectively inserted into the temporary table
.<code class="language-sql">CREATE PROC getBusinessLineHistory AS BEGIN SELECT * FROM sys.databases END GO SELECT * INTO #MyTempTable FROM OPENROWSET('SQLNCLI', 'Server=(local)\SQL2008;Trusted_Connection=yes;', 'EXEC getBusinessLineHistory') SELECT * FROM #MyTempTable</code>
The above is the detailed content of How to Insert Stored Procedure Results into a Temporary Table Using OPENROWSET?. For more information, please follow other related articles on the PHP Chinese website!