I create own table type
CREATE TYPE [dbo].[ObjectsList] AS TABLE( [Id] [int] NOT NULL, PRIMARY KEY CLUSTERED ( [Id] ASC )WITH (IGNORE_DUP_KEY = OFF) ) GO
and when I want to pass this Type as parameter like
CREATE PROCEDURE [dbo].[GetData](@DataIds ObjectsList READONLY)
how should I pass it in EXEC GetData ????
First a Table Variable of User Defined Table Type has to be created of the same schema as that of the Table Valued parameter. Then it is passed as Parameter to the Stored Procedure and the Stored Procedure is executed using the EXEC command in SQL Server.
You cannot pass table-valued parameters to CLR user-defined functions. Table-valued parameters can only be indexed to support UNIQUE or PRIMARY KEY constraints. SQL Server does not maintain statistics on table-valued parameters. Table-valued parameters are read-only in Transact-SQL code.
Look at this
You can find an example
DECLARE @data ObjectList INSERT @data (Id) VALUES (1) EXEC GetData @data
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With