Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 将存储过程结果存储到Azure数据仓库中的临时表中_Sql Server_Azure_Stored Procedures_Azure Sqldw - Fatal编程技术网

Sql server 将存储过程结果存储到Azure数据仓库中的临时表中

Sql server 将存储过程结果存储到Azure数据仓库中的临时表中,sql-server,azure,stored-procedures,azure-sqldw,Sql Server,Azure,Stored Procedures,Azure Sqldw,在Azure数据仓库中,我有一个存储过程,它将返回选择命令的结果 如何将存储过程结果推送到临时表中 我尝试了下面的查询,它返回了一条错误消息 CREATE TABLE #temp (name varchar(255), created_date datetime) GO INSERT INTO #temp EXEC sp_testproc 输出消息: Msg 103010, Level 16, State 1, Line 3 Parse error at line: 2, column: 1:

Azure数据仓库
中,我有一个
存储过程
,它将返回
选择
命令的结果

如何将
存储过程
结果推送到临时表中

我尝试了下面的查询,它返回了一条错误消息

CREATE TABLE #temp
(name varchar(255), created_date datetime)
GO
INSERT INTO #temp
EXEC sp_testproc
输出消息:

Msg 103010, Level 16, State 1, Line 3
Parse error at line: 2, column: 1: Incorrect syntax near 'EXEC'.

Azure SQL数据仓库不支持
插入。。。执行
根据。但是,临时表也有不同的作用域,这意味着可以在创建临时表的存储过程之外查看临时表。只需在存储过程中创建临时表,即可在存储过程执行后查看,例如:

IF OBJECT_ID('dbo.usp_getTableNames') IS NOT NULL DROP PROC dbo.usp_getTableNames;
GO

CREATE PROC dbo.usp_getTableNames
AS

    -- Drop table if already exists
    IF OBJECT_ID('tempdb..#tables') IS NOT NULL DROP TABLE #tables;

    -- Create temp table for viewing outside stored procedure
    CREATE TABLE #tables
    (
        [object_id]     INT NOT NULL,
        name            SYSNAME NOT NULL
    )
    WITH
    (
        DISTRIBUTION = HASH([object_id]),
        HEAP
    );


    INSERT INTO #tables
    SELECT object_id, name
    FROM sys.tables;

GO

-- Run the proc
EXEC dbo.usp_getTableNames;
GO


-- The table table is still available for reading outside the scope of the stored procedure
SELECT *
FROM #tables;

DROP TABLE #tables;
GO

本文的“模块化代码”部分提供了一个类似的示例。这只是做事的顺序稍有不同。

是否有存储系统存储过程结果的方法,例如sp_spaceused?嗨,你找到解决方案了吗?我对推送系统sp结果特别感兴趣。不,我没有。另外,我现在不在Azure DW工作。