Get proc selection output schema

I would like to put the results of a stored procedure in a temp table. It seems that the temporary table should be predefined and the INSERT INTO will not work.

Does anyone know how to get the record set schema returned from the select statement?

sp_help only gets parameter information.

+3
source share
3 answers

You should be able to insert into a temporary table without specifying a schema using OPENQUERY:

SELECT * INTO #TempTable
FROM OPENQUERY(ServerName, β€˜EXEC DataBaseName.dbo.StoredProcedureName paramvalues1, paramvalues1β€²)

Where ServerName is the name of your Sql server instance. See this article for more information.

+4
source

, INSERT INTO, ? , .

, , , , SP.

, DDL SP. , .

0

If you are able, change the stored procedure to a user-defined function.

http://www.scottstonehouse.ca/blog/2007/03/stored-procedures-are-not-parameterized.html

0
source

Source: https://habr.com/ru/post/1705732/


All Articles