Home > Database > Mysql Tutorial > How to Insert Stored Procedure Results into a Temporary Table Using OPENROWSET?

How to Insert Stored Procedure Results into a Temporary Table Using OPENROWSET?

DDD
Release: 2025-01-25 02:46:09
Original
246 people have browsed it

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
sp_configure 'Show Advanced Options', 1
GO
RECONFIGURE
GO
sp_configure 'Ad Hoc Distributed Queries', 1
GO
RECONFIGURE
GO
Copy after login
return the data of the

table. By <将>, the results of the storage procedure can be effectively inserted into the temporary table

.
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
Copy after login

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template