Michael
Michael

Reputation: 13626

Executing SQL troubles

I try to execute my stored procedure but I have trouble with it.

One of the parameters pf the stored procedure is defined like that:

@MerchId [dbo].[intArray] READONLY,

And it's a user-defined table type.

Here is definition of the above type:

CREATE TYPE [dbo].[intArray] AS TABLE ([num] [int] NULL)

Here is how I try to set value and execute:

exec    @return_value = [dbo].[SPMerchData],
        @MerchId = [1,2,3]

But I get a syntax error.

Any idea how can I set value to @MerchId variable to execute the stored procedure?

Upvotes: 2

Views: 59

Answers (1)

Tyron78
Tyron78

Reputation: 4187

You should declare a variable and pass it to your procedure:

DECLARE @t intArray;
INSERT INTO @t VALUES (1), (2), (3);

exec    @return_value = [dbo].[SPMerchData],
        @MerchId = @t

Upvotes: 5

Related Questions