How to store the result of **DBCC PDW_SHOWSPACEUSED("dbo.TableName")** in a Temporary table in Parallel Data Warehousing (APS PDW)?

Sunny Singh 1 Reputation point
2020-10-03T11:36:04.993+00:00

How to store the result of DBCC PDW_SHOWSPACEUSED("dbo.TableName") in a Temporary table in Parallel Data Warehousing (APS PDW)?

Below is my query which is not working.

create table #TempSpace(
[ROWS] bigint,
RESERVED_SPACE bigint,
DATA_SPACE bigint,
INDEX_SPACE bigint,
UNUSED_SPACE bigint,
PDW_NODE_ID bigint,
DISTRIBUTION_ID bigint
)

insert #TempSpace([ROWS],RESERVED_SPACE,DATA_SPACE,INDEX_SPACE,UNUSED_SPACE,PDW_NODE_ID,DISTRIBUTION_ID) EXEC('DBCC PDW_SHOWSPACEUSED("dbo.TableName")')

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,868 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,562 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Erland Sommarskog 102.2K Reputation points
    2020-10-03T12:08:06.1+00:00

    You often have to add WITH TABLERESULTS to DBCC commands to get a format you can work with.

    However, I can't say whether it works in particular case. I don't use APS myself.

    0 comments No comments

  2. Cris Zhan-MSFT 6,606 Reputation points
    2020-10-05T08:54:34.477+00:00

    Hi anonymous user,

    Sorry I am not familiar with Parallel Data Warehouse. Not sure if this statement is supported.

    Azure SQL Data Warehouse does not support INSERT ... EXEC
    https://learn.microsoft.com/en-gb/azure/sql-data-warehouse/sql-data-warehouse-develop-stored-procedures#insertexecute


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  3. Anthony Perkins 1 Reputation point
    2021-02-05T21:13:05.433+00:00

    Sorry, I am late to this, but the only way to do this with APS (PDW) or Synapse (ADW) is using Powershell (let me know if you need code for this, but it is pretty trivial) or .NET, as there is no support for WITH RESULTSETS when using DBCC PDW_SHOWSPACEUSED

    And no there is also no support for INSERT ... EXEC on either APS or Synapse. This is from the INSERT (Transact-SQL)
    -- Syntax for Azure Synapse Analytics and Parallel Data Warehouse

    INSERT INTO { database_name.schema_name.table_name | schema_name.table_name | table_name }
    [ ( column_name [ ,...n ] ) ]
    {
    VALUES ( { NULL | expression } )
    | SELECT <select_criteria>
    }
    [ OPTION ( <query_option> [ ,...n ] ) ]
    [;]

    Anthony

    0 comments No comments