SQL Server 2008 - How do i return a User-Defined Table Type from a Table-Valued Function?











up vote
38
down vote

favorite
2












Here's my user-defined table type...



CREATE TYPE [dbo].[FooType] AS TABLE(
[Bar] [INT],
)


This is what ive had to do in my table-valued function to return the type:



CREATE FUNCTION [dbo].[GetFoos]
RETURN @FooTypes TABLE ([Bar] [INT])
INSERT INTO @FooTypes (1)
RETURN


Basically, im having to re-declare my type definition in the RETURN statement of the function. Isnt there a way i can simply declare the type in the RETURN statement?



I would have thought this would work:



CREATE FUNCTION [dbo].[GetFoos]
RETURN @FooTypes [FooType]
INSERT INTO @FooTypes (1)
RETURN


Cannot find any help on MSDN/Google regarding this....anyone?



EDIT



I unmarked my answer, and bumping this question - as i am encountering the same scenario 6 months later.



Does anyone have any idea if it's possible to return a user defined table type from a table valued function? If not, is there a better workaround other than what i have done? (re-declare the type again).










share|improve this question
























  • Confirmed still not possible with 2014.
    – dudeNumber4
    Jan 22 '15 at 14:11















up vote
38
down vote

favorite
2












Here's my user-defined table type...



CREATE TYPE [dbo].[FooType] AS TABLE(
[Bar] [INT],
)


This is what ive had to do in my table-valued function to return the type:



CREATE FUNCTION [dbo].[GetFoos]
RETURN @FooTypes TABLE ([Bar] [INT])
INSERT INTO @FooTypes (1)
RETURN


Basically, im having to re-declare my type definition in the RETURN statement of the function. Isnt there a way i can simply declare the type in the RETURN statement?



I would have thought this would work:



CREATE FUNCTION [dbo].[GetFoos]
RETURN @FooTypes [FooType]
INSERT INTO @FooTypes (1)
RETURN


Cannot find any help on MSDN/Google regarding this....anyone?



EDIT



I unmarked my answer, and bumping this question - as i am encountering the same scenario 6 months later.



Does anyone have any idea if it's possible to return a user defined table type from a table valued function? If not, is there a better workaround other than what i have done? (re-declare the type again).










share|improve this question
























  • Confirmed still not possible with 2014.
    – dudeNumber4
    Jan 22 '15 at 14:11













up vote
38
down vote

favorite
2









up vote
38
down vote

favorite
2






2





Here's my user-defined table type...



CREATE TYPE [dbo].[FooType] AS TABLE(
[Bar] [INT],
)


This is what ive had to do in my table-valued function to return the type:



CREATE FUNCTION [dbo].[GetFoos]
RETURN @FooTypes TABLE ([Bar] [INT])
INSERT INTO @FooTypes (1)
RETURN


Basically, im having to re-declare my type definition in the RETURN statement of the function. Isnt there a way i can simply declare the type in the RETURN statement?



I would have thought this would work:



CREATE FUNCTION [dbo].[GetFoos]
RETURN @FooTypes [FooType]
INSERT INTO @FooTypes (1)
RETURN


Cannot find any help on MSDN/Google regarding this....anyone?



EDIT



I unmarked my answer, and bumping this question - as i am encountering the same scenario 6 months later.



Does anyone have any idea if it's possible to return a user defined table type from a table valued function? If not, is there a better workaround other than what i have done? (re-declare the type again).










share|improve this question















Here's my user-defined table type...



CREATE TYPE [dbo].[FooType] AS TABLE(
[Bar] [INT],
)


This is what ive had to do in my table-valued function to return the type:



CREATE FUNCTION [dbo].[GetFoos]
RETURN @FooTypes TABLE ([Bar] [INT])
INSERT INTO @FooTypes (1)
RETURN


Basically, im having to re-declare my type definition in the RETURN statement of the function. Isnt there a way i can simply declare the type in the RETURN statement?



I would have thought this would work:



CREATE FUNCTION [dbo].[GetFoos]
RETURN @FooTypes [FooType]
INSERT INTO @FooTypes (1)
RETURN


Cannot find any help on MSDN/Google regarding this....anyone?



EDIT



I unmarked my answer, and bumping this question - as i am encountering the same scenario 6 months later.



Does anyone have any idea if it's possible to return a user defined table type from a table valued function? If not, is there a better workaround other than what i have done? (re-declare the type again).







sql-server tsql sql-server-2008 user-defined-functions user-defined-types






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 16 '10 at 8:41

























asked Jun 22 '10 at 1:08









RPM1984

54.8k44196303




54.8k44196303












  • Confirmed still not possible with 2014.
    – dudeNumber4
    Jan 22 '15 at 14:11


















  • Confirmed still not possible with 2014.
    – dudeNumber4
    Jan 22 '15 at 14:11
















Confirmed still not possible with 2014.
– dudeNumber4
Jan 22 '15 at 14:11




Confirmed still not possible with 2014.
– dudeNumber4
Jan 22 '15 at 14:11












5 Answers
5






active

oldest

votes

















up vote
31
down vote













Even though you can not return the UDTT from a function, you can return a table variable and receive it in a UDTT as long as the schema match. The following code is tested in SQL Server 2008 R2



-- Create the UDTT



CREATE TYPE dbo.MyCustomUDDT AS TABLE
(
FieldOne varchar (512),
FieldTwo varchar(1024)
)


-- Declare your variables



DECLARE @uddt MyCustomUDDT;
DECLARE @Modifieduddt MyCustomUDDT;


// Call the function



INSERT INTO @Modifieduddt SELECT * FROM dbo.MyUDF(@uddt);


Function signature



CREATE FUNCTION dbo.MyUDF(@localUDDT MyCustomUDDT)
RETURNS @tableVar TABLE
(
FieldOne varchar (512),
FieldTwo varchar(1024)
)
AS
BEGIN
--Modify your variable here
RETURN
END


Hopefully this will help somebody.






share|improve this answer



















  • 4




    This is a better answer than the currently marked one.
    – slugster
    Jan 11 '17 at 3:34


















up vote
9
down vote



accepted










Ok - so it cant be done.



Easy enough to duplicate the table definition in the return type (with the use of scripting).



Still - hopefully this issue gets rectified in the next version of SQL Server.






share|improve this answer

















  • 6




    I know this is an old question, but IMVHO you should unmark your answer and mark the answer from James as it explains and solves the issue nicely.
    – slugster
    Jan 11 '17 at 3:36


















up vote
2
down vote













The syntax for CREATE FUNCTION indicates that the only way to define a table return type is by listing columns and types, a <table_type_definition>. Even SQL Server "Denali" has the same definition for <table_type_definition>. Although strangely, it's syntax doesn't include multi-statement Table valued functions, or anything else that references this fragment.






share|improve this answer

















  • 3




    So i guess the answer is still no. :) Dang. All im trying to achieve here is a type of "contract" between the UDF and the code that is calling it. Keeps the T-SQL "D-R-Y". There's not much point even using the UDTT here if i can't return it from the function. Oh well. Thanks anyway.
    – RPM1984
    Dec 16 '10 at 9:17




















up vote
0
down vote













I do not believe this is possible. You cannot use a UDTT as the return type of a Scalar-Valued Function because it is not a scalar value. You also cannot replace the table declaration of a Table-Valued Function with a UDTT. Repeating the table definition seems to be the only option. If we knew why you were doing this, perhaps we could find an alternative.






share|improve this answer

















  • 1




    I know i cant return a UDT from a Scalar function. But in regards to Table functions - you are able to return tables (or table variables). A UDT is just another table so cant see why you cant return it. Oh well, maybe in the next version of SS. =) Im doing this because i have a table variable which was being duplicated amongst numerous functions/procs. Therefore i put it in an UDT to prevent being "DRY". Easier to maintain, etc.
    – RPM1984
    Jun 25 '10 at 0:01




















up vote
0
down vote













Nope, afraid not at the moment, as per this question. And the following from msdn:



Restrictions



Table-valued parameters have the following restrictions:




  • SQL Server does not maintain statistics on columns of table-valued parameters.


  • Table-valued parameters must be passed as input READONLY parameters to Transact-SQL routines. You cannot perform DML operations such as UPDATE, DELETE, or INSERT on a table-valued parameter in the body of a routine.


  • You cannot use a table-valued parameter as target of a SELECT INTO or INSERT EXEC statement. A table-valued parameter can be in the FROM clause of SELECT INTO or in the INSERT EXEC string or stored-procedure.







share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f3089553%2fsql-server-2008-how-do-i-return-a-user-defined-table-type-from-a-table-valued%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    5 Answers
    5






    active

    oldest

    votes








    5 Answers
    5






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    31
    down vote













    Even though you can not return the UDTT from a function, you can return a table variable and receive it in a UDTT as long as the schema match. The following code is tested in SQL Server 2008 R2



    -- Create the UDTT



    CREATE TYPE dbo.MyCustomUDDT AS TABLE
    (
    FieldOne varchar (512),
    FieldTwo varchar(1024)
    )


    -- Declare your variables



    DECLARE @uddt MyCustomUDDT;
    DECLARE @Modifieduddt MyCustomUDDT;


    // Call the function



    INSERT INTO @Modifieduddt SELECT * FROM dbo.MyUDF(@uddt);


    Function signature



    CREATE FUNCTION dbo.MyUDF(@localUDDT MyCustomUDDT)
    RETURNS @tableVar TABLE
    (
    FieldOne varchar (512),
    FieldTwo varchar(1024)
    )
    AS
    BEGIN
    --Modify your variable here
    RETURN
    END


    Hopefully this will help somebody.






    share|improve this answer



















    • 4




      This is a better answer than the currently marked one.
      – slugster
      Jan 11 '17 at 3:34















    up vote
    31
    down vote













    Even though you can not return the UDTT from a function, you can return a table variable and receive it in a UDTT as long as the schema match. The following code is tested in SQL Server 2008 R2



    -- Create the UDTT



    CREATE TYPE dbo.MyCustomUDDT AS TABLE
    (
    FieldOne varchar (512),
    FieldTwo varchar(1024)
    )


    -- Declare your variables



    DECLARE @uddt MyCustomUDDT;
    DECLARE @Modifieduddt MyCustomUDDT;


    // Call the function



    INSERT INTO @Modifieduddt SELECT * FROM dbo.MyUDF(@uddt);


    Function signature



    CREATE FUNCTION dbo.MyUDF(@localUDDT MyCustomUDDT)
    RETURNS @tableVar TABLE
    (
    FieldOne varchar (512),
    FieldTwo varchar(1024)
    )
    AS
    BEGIN
    --Modify your variable here
    RETURN
    END


    Hopefully this will help somebody.






    share|improve this answer



















    • 4




      This is a better answer than the currently marked one.
      – slugster
      Jan 11 '17 at 3:34













    up vote
    31
    down vote










    up vote
    31
    down vote









    Even though you can not return the UDTT from a function, you can return a table variable and receive it in a UDTT as long as the schema match. The following code is tested in SQL Server 2008 R2



    -- Create the UDTT



    CREATE TYPE dbo.MyCustomUDDT AS TABLE
    (
    FieldOne varchar (512),
    FieldTwo varchar(1024)
    )


    -- Declare your variables



    DECLARE @uddt MyCustomUDDT;
    DECLARE @Modifieduddt MyCustomUDDT;


    // Call the function



    INSERT INTO @Modifieduddt SELECT * FROM dbo.MyUDF(@uddt);


    Function signature



    CREATE FUNCTION dbo.MyUDF(@localUDDT MyCustomUDDT)
    RETURNS @tableVar TABLE
    (
    FieldOne varchar (512),
    FieldTwo varchar(1024)
    )
    AS
    BEGIN
    --Modify your variable here
    RETURN
    END


    Hopefully this will help somebody.






    share|improve this answer














    Even though you can not return the UDTT from a function, you can return a table variable and receive it in a UDTT as long as the schema match. The following code is tested in SQL Server 2008 R2



    -- Create the UDTT



    CREATE TYPE dbo.MyCustomUDDT AS TABLE
    (
    FieldOne varchar (512),
    FieldTwo varchar(1024)
    )


    -- Declare your variables



    DECLARE @uddt MyCustomUDDT;
    DECLARE @Modifieduddt MyCustomUDDT;


    // Call the function



    INSERT INTO @Modifieduddt SELECT * FROM dbo.MyUDF(@uddt);


    Function signature



    CREATE FUNCTION dbo.MyUDF(@localUDDT MyCustomUDDT)
    RETURNS @tableVar TABLE
    (
    FieldOne varchar (512),
    FieldTwo varchar(1024)
    )
    AS
    BEGIN
    --Modify your variable here
    RETURN
    END


    Hopefully this will help somebody.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 12 '17 at 7:39

























    answered Nov 26 '14 at 22:04









    James Poulose

    1,5031318




    1,5031318








    • 4




      This is a better answer than the currently marked one.
      – slugster
      Jan 11 '17 at 3:34














    • 4




      This is a better answer than the currently marked one.
      – slugster
      Jan 11 '17 at 3:34








    4




    4




    This is a better answer than the currently marked one.
    – slugster
    Jan 11 '17 at 3:34




    This is a better answer than the currently marked one.
    – slugster
    Jan 11 '17 at 3:34












    up vote
    9
    down vote



    accepted










    Ok - so it cant be done.



    Easy enough to duplicate the table definition in the return type (with the use of scripting).



    Still - hopefully this issue gets rectified in the next version of SQL Server.






    share|improve this answer

















    • 6




      I know this is an old question, but IMVHO you should unmark your answer and mark the answer from James as it explains and solves the issue nicely.
      – slugster
      Jan 11 '17 at 3:36















    up vote
    9
    down vote



    accepted










    Ok - so it cant be done.



    Easy enough to duplicate the table definition in the return type (with the use of scripting).



    Still - hopefully this issue gets rectified in the next version of SQL Server.






    share|improve this answer

















    • 6




      I know this is an old question, but IMVHO you should unmark your answer and mark the answer from James as it explains and solves the issue nicely.
      – slugster
      Jan 11 '17 at 3:36













    up vote
    9
    down vote



    accepted







    up vote
    9
    down vote



    accepted






    Ok - so it cant be done.



    Easy enough to duplicate the table definition in the return type (with the use of scripting).



    Still - hopefully this issue gets rectified in the next version of SQL Server.






    share|improve this answer












    Ok - so it cant be done.



    Easy enough to duplicate the table definition in the return type (with the use of scripting).



    Still - hopefully this issue gets rectified in the next version of SQL Server.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jun 28 '10 at 3:12









    RPM1984

    54.8k44196303




    54.8k44196303








    • 6




      I know this is an old question, but IMVHO you should unmark your answer and mark the answer from James as it explains and solves the issue nicely.
      – slugster
      Jan 11 '17 at 3:36














    • 6




      I know this is an old question, but IMVHO you should unmark your answer and mark the answer from James as it explains and solves the issue nicely.
      – slugster
      Jan 11 '17 at 3:36








    6




    6




    I know this is an old question, but IMVHO you should unmark your answer and mark the answer from James as it explains and solves the issue nicely.
    – slugster
    Jan 11 '17 at 3:36




    I know this is an old question, but IMVHO you should unmark your answer and mark the answer from James as it explains and solves the issue nicely.
    – slugster
    Jan 11 '17 at 3:36










    up vote
    2
    down vote













    The syntax for CREATE FUNCTION indicates that the only way to define a table return type is by listing columns and types, a <table_type_definition>. Even SQL Server "Denali" has the same definition for <table_type_definition>. Although strangely, it's syntax doesn't include multi-statement Table valued functions, or anything else that references this fragment.






    share|improve this answer

















    • 3




      So i guess the answer is still no. :) Dang. All im trying to achieve here is a type of "contract" between the UDF and the code that is calling it. Keeps the T-SQL "D-R-Y". There's not much point even using the UDTT here if i can't return it from the function. Oh well. Thanks anyway.
      – RPM1984
      Dec 16 '10 at 9:17

















    up vote
    2
    down vote













    The syntax for CREATE FUNCTION indicates that the only way to define a table return type is by listing columns and types, a <table_type_definition>. Even SQL Server "Denali" has the same definition for <table_type_definition>. Although strangely, it's syntax doesn't include multi-statement Table valued functions, or anything else that references this fragment.






    share|improve this answer

















    • 3




      So i guess the answer is still no. :) Dang. All im trying to achieve here is a type of "contract" between the UDF and the code that is calling it. Keeps the T-SQL "D-R-Y". There's not much point even using the UDTT here if i can't return it from the function. Oh well. Thanks anyway.
      – RPM1984
      Dec 16 '10 at 9:17















    up vote
    2
    down vote










    up vote
    2
    down vote









    The syntax for CREATE FUNCTION indicates that the only way to define a table return type is by listing columns and types, a <table_type_definition>. Even SQL Server "Denali" has the same definition for <table_type_definition>. Although strangely, it's syntax doesn't include multi-statement Table valued functions, or anything else that references this fragment.






    share|improve this answer












    The syntax for CREATE FUNCTION indicates that the only way to define a table return type is by listing columns and types, a <table_type_definition>. Even SQL Server "Denali" has the same definition for <table_type_definition>. Although strangely, it's syntax doesn't include multi-statement Table valued functions, or anything else that references this fragment.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Dec 16 '10 at 9:01









    Damien_The_Unbeliever

    190k17243329




    190k17243329








    • 3




      So i guess the answer is still no. :) Dang. All im trying to achieve here is a type of "contract" between the UDF and the code that is calling it. Keeps the T-SQL "D-R-Y". There's not much point even using the UDTT here if i can't return it from the function. Oh well. Thanks anyway.
      – RPM1984
      Dec 16 '10 at 9:17
















    • 3




      So i guess the answer is still no. :) Dang. All im trying to achieve here is a type of "contract" between the UDF and the code that is calling it. Keeps the T-SQL "D-R-Y". There's not much point even using the UDTT here if i can't return it from the function. Oh well. Thanks anyway.
      – RPM1984
      Dec 16 '10 at 9:17










    3




    3




    So i guess the answer is still no. :) Dang. All im trying to achieve here is a type of "contract" between the UDF and the code that is calling it. Keeps the T-SQL "D-R-Y". There's not much point even using the UDTT here if i can't return it from the function. Oh well. Thanks anyway.
    – RPM1984
    Dec 16 '10 at 9:17






    So i guess the answer is still no. :) Dang. All im trying to achieve here is a type of "contract" between the UDF and the code that is calling it. Keeps the T-SQL "D-R-Y". There's not much point even using the UDTT here if i can't return it from the function. Oh well. Thanks anyway.
    – RPM1984
    Dec 16 '10 at 9:17












    up vote
    0
    down vote













    I do not believe this is possible. You cannot use a UDTT as the return type of a Scalar-Valued Function because it is not a scalar value. You also cannot replace the table declaration of a Table-Valued Function with a UDTT. Repeating the table definition seems to be the only option. If we knew why you were doing this, perhaps we could find an alternative.






    share|improve this answer

















    • 1




      I know i cant return a UDT from a Scalar function. But in regards to Table functions - you are able to return tables (or table variables). A UDT is just another table so cant see why you cant return it. Oh well, maybe in the next version of SS. =) Im doing this because i have a table variable which was being duplicated amongst numerous functions/procs. Therefore i put it in an UDT to prevent being "DRY". Easier to maintain, etc.
      – RPM1984
      Jun 25 '10 at 0:01

















    up vote
    0
    down vote













    I do not believe this is possible. You cannot use a UDTT as the return type of a Scalar-Valued Function because it is not a scalar value. You also cannot replace the table declaration of a Table-Valued Function with a UDTT. Repeating the table definition seems to be the only option. If we knew why you were doing this, perhaps we could find an alternative.






    share|improve this answer

















    • 1




      I know i cant return a UDT from a Scalar function. But in regards to Table functions - you are able to return tables (or table variables). A UDT is just another table so cant see why you cant return it. Oh well, maybe in the next version of SS. =) Im doing this because i have a table variable which was being duplicated amongst numerous functions/procs. Therefore i put it in an UDT to prevent being "DRY". Easier to maintain, etc.
      – RPM1984
      Jun 25 '10 at 0:01















    up vote
    0
    down vote










    up vote
    0
    down vote









    I do not believe this is possible. You cannot use a UDTT as the return type of a Scalar-Valued Function because it is not a scalar value. You also cannot replace the table declaration of a Table-Valued Function with a UDTT. Repeating the table definition seems to be the only option. If we knew why you were doing this, perhaps we could find an alternative.






    share|improve this answer












    I do not believe this is possible. You cannot use a UDTT as the return type of a Scalar-Valued Function because it is not a scalar value. You also cannot replace the table declaration of a Table-Valued Function with a UDTT. Repeating the table definition seems to be the only option. If we knew why you were doing this, perhaps we could find an alternative.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jun 23 '10 at 13:44









    Schmalls

    92411218




    92411218








    • 1




      I know i cant return a UDT from a Scalar function. But in regards to Table functions - you are able to return tables (or table variables). A UDT is just another table so cant see why you cant return it. Oh well, maybe in the next version of SS. =) Im doing this because i have a table variable which was being duplicated amongst numerous functions/procs. Therefore i put it in an UDT to prevent being "DRY". Easier to maintain, etc.
      – RPM1984
      Jun 25 '10 at 0:01
















    • 1




      I know i cant return a UDT from a Scalar function. But in regards to Table functions - you are able to return tables (or table variables). A UDT is just another table so cant see why you cant return it. Oh well, maybe in the next version of SS. =) Im doing this because i have a table variable which was being duplicated amongst numerous functions/procs. Therefore i put it in an UDT to prevent being "DRY". Easier to maintain, etc.
      – RPM1984
      Jun 25 '10 at 0:01










    1




    1




    I know i cant return a UDT from a Scalar function. But in regards to Table functions - you are able to return tables (or table variables). A UDT is just another table so cant see why you cant return it. Oh well, maybe in the next version of SS. =) Im doing this because i have a table variable which was being duplicated amongst numerous functions/procs. Therefore i put it in an UDT to prevent being "DRY". Easier to maintain, etc.
    – RPM1984
    Jun 25 '10 at 0:01






    I know i cant return a UDT from a Scalar function. But in regards to Table functions - you are able to return tables (or table variables). A UDT is just another table so cant see why you cant return it. Oh well, maybe in the next version of SS. =) Im doing this because i have a table variable which was being duplicated amongst numerous functions/procs. Therefore i put it in an UDT to prevent being "DRY". Easier to maintain, etc.
    – RPM1984
    Jun 25 '10 at 0:01












    up vote
    0
    down vote













    Nope, afraid not at the moment, as per this question. And the following from msdn:



    Restrictions



    Table-valued parameters have the following restrictions:




    • SQL Server does not maintain statistics on columns of table-valued parameters.


    • Table-valued parameters must be passed as input READONLY parameters to Transact-SQL routines. You cannot perform DML operations such as UPDATE, DELETE, or INSERT on a table-valued parameter in the body of a routine.


    • You cannot use a table-valued parameter as target of a SELECT INTO or INSERT EXEC statement. A table-valued parameter can be in the FROM clause of SELECT INTO or in the INSERT EXEC string or stored-procedure.







    share|improve this answer



























      up vote
      0
      down vote













      Nope, afraid not at the moment, as per this question. And the following from msdn:



      Restrictions



      Table-valued parameters have the following restrictions:




      • SQL Server does not maintain statistics on columns of table-valued parameters.


      • Table-valued parameters must be passed as input READONLY parameters to Transact-SQL routines. You cannot perform DML operations such as UPDATE, DELETE, or INSERT on a table-valued parameter in the body of a routine.


      • You cannot use a table-valued parameter as target of a SELECT INTO or INSERT EXEC statement. A table-valued parameter can be in the FROM clause of SELECT INTO or in the INSERT EXEC string or stored-procedure.







      share|improve this answer

























        up vote
        0
        down vote










        up vote
        0
        down vote









        Nope, afraid not at the moment, as per this question. And the following from msdn:



        Restrictions



        Table-valued parameters have the following restrictions:




        • SQL Server does not maintain statistics on columns of table-valued parameters.


        • Table-valued parameters must be passed as input READONLY parameters to Transact-SQL routines. You cannot perform DML operations such as UPDATE, DELETE, or INSERT on a table-valued parameter in the body of a routine.


        • You cannot use a table-valued parameter as target of a SELECT INTO or INSERT EXEC statement. A table-valued parameter can be in the FROM clause of SELECT INTO or in the INSERT EXEC string or stored-procedure.







        share|improve this answer














        Nope, afraid not at the moment, as per this question. And the following from msdn:



        Restrictions



        Table-valued parameters have the following restrictions:




        • SQL Server does not maintain statistics on columns of table-valued parameters.


        • Table-valued parameters must be passed as input READONLY parameters to Transact-SQL routines. You cannot perform DML operations such as UPDATE, DELETE, or INSERT on a table-valued parameter in the body of a routine.


        • You cannot use a table-valued parameter as target of a SELECT INTO or INSERT EXEC statement. A table-valued parameter can be in the FROM clause of SELECT INTO or in the INSERT EXEC string or stored-procedure.








        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited May 23 '17 at 12:03









        Community

        11




        11










        answered Dec 17 '10 at 8:26









        Timbo

        3,71622025




        3,71622025






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f3089553%2fsql-server-2008-how-do-i-return-a-user-defined-table-type-from-a-table-valued%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Post-Redirect-Get with Spring WebFlux and Thymeleaf

            Xamarin.form Move up view when keyboard appear

            JBPM : POST request for execute process go wrong