sql - Insérer les résultats d'une procédure stockée dans un tableau temporaire

Mots clés : sqlsql-serversql-server-2005tsqlstored-proceduressql

meilleur 5 Réponses sql - Insérer les résultats d'une procédure stockée dans un tableau temporaire

vote vote

93

CREATE PROC getBusinessLineHistory AS BEGIN     SELECT * FROM sys.databases END GO  sp_configure 'Show Advanced Options', 1 GO RECONFIGURE GO sp_configure 'Ad Hoc Distributed Queries', 1 GO RECONFIGURE GO  SELECT * INTO #MyTempTable FROM OPENROWSET('SQLNCLI', 'Server=(local)\SQL2008;Trusted_Connection=yes;',      'EXEC getBusinessLineHistory')  SELECT * FROM #MyTempTable 
vote vote

81

CREATE TABLE #tmpBus (    COL1 INT,    COL2 INT )  INSERT INTO #tmpBus Exec SpGetRecords 'Params' 
vote vote

74

--INSERT...EXECUTE procedure example INSERT author_sales EXECUTE get_author_sales 
vote vote

70

CREATE FUNCTION CustomersByRegion  (       @RegionID int   ) RETURNS TABLE  AS RETURN    SELECT *   FROM customers   WHERE RegionID = @RegionID GO 
SELECT * FROM CustomersbyRegion(1) 
SELECT * INTO CustList FROM CustomersbyRegion(1) 
CREATE PROCEDURE uspCustomersByRegion  (       @regionID int   ) AS BEGIN      SELECT * FROM CustomersbyRegion(@regionID); END GO 
vote vote

58

Select @@ServerName EXEC sp_serveroption @@ServerName, 'DATA ACCESS', TRUE  SELECT  * INTO    #tmpTable FROM    OPENQUERY(YOURSERVERNAME, 'EXEC db.schema.sproc 1') 

Questions similaires