Pass datatable as a parameter into a stored procedure

  • I learn how to pass datatable (created from app) to stored procedure from here.
    https://technet.microsoft.com/en-us/library/bb522526(v=sql.105).aspx

    USE AdventureWorks2008R2;
    GO
    /* Create a user-defined table type */
    CREATE TYPE LocationTableType AS TABLE (
    LocationName VARCHAR(50),
    CostRate INT );
    GO

    Question:
    Since datatable is created from a Excel file in which there are about 100 columns.
    Do I need to define all columns in user-defined table? 

  • No, you could create a staging table by using the import wizard, save the package to the file system tweak as necessary in SSDT to insert or update the columns you care about in the target table.

  • adonetok - Wednesday, February 14, 2018 8:59 AM

    I learn how to pass datatable (created from app) to stored procedure from here.
    https://technet.microsoft.com/en-us/library/bb522526(v=sql.105).aspx

    USE AdventureWorks2008R2;
    GO
    /* Create a user-defined table type */
    CREATE TYPE LocationTableType AS TABLE (
    LocationName VARCHAR(50),
    CostRate INT );
    GO

    Question:
    Since datatable is created from a Excel file in which there are about 100 columns.
    Do I need to define all columns in user-defined table? 

    I'm afraid, yes, if you want to pass user defined table type to stored procedure.

    GASQL.com - Focus on Database and Cloud

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply