Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass TABLE as parameter without creating TYPE

Tags:

sql-server

I know it is possible to create a stored procedure and pass a TABLE as parameter by doing the following:

CREATE TYPE MyTableType AS TABLE (Id UNIQUEIDENTIFIER)

CREATE PROCEDURE MyProcedure
    @ids MyTableType READONLY
AS
...

I don't want to create a TYPE as above, because I was told to not create type dependencies in the database. So I want to do the following:

CREATE PROCEDURE MyProcedure
    @ids TABLE (Id UNIQUEIDENTIFIER)
AS

But for some reason I get error highlights. Am I doing something wrong in the syntax? Or is this not possible to do?

like image 996
Mari Faleiros Avatar asked Jul 22 '16 18:07

Mari Faleiros


1 Answers

I don't think it's possible to declare a table type inline like you're trying to do. The first line in this article on table-valued parameters says:

Table-valued parameters are declared by using user-defined table types.

like image 183
Joe Farrell Avatar answered Oct 23 '22 05:10

Joe Farrell