I’m having a procedure and some custom types to pass some data to it:
CREATE TYPE StringList AS TABLE
(Value NVARCHAR(255));
GO
CREATE TYPE KeyValueList AS TABLE
(
Id uniqueidentifier,
Value NVARCHAR(255));
GO
CREATE PROCEDURE
#update_AttributeFormel(
@modelPrefix NVARCHAR(255),
@definitionNeutralName NVARCHAR(255),
@newFormula NVARCHAR(255),
@providersToRemove StringList READONLY,
@providersToAdd KeyValueList READONLY)
AS ....
The ManagementStudio does not show any error (as it would when i comment out the type declaration) but when i execute the script, i’m getting the following errors:
Msg 2715, Level 16, State 3, Procedure #update_AttributeFormel, Line 2
Column, parameter, or variable #4: Cannot find data type StringList.
Parameter or variable '@providersToRemove' has an invalid data type.
Msg 2715, Level 16, State 3, Procedure #update_AttributeFormel, Line 2
Column, parameter, or variable #5: Cannot find data type KeyValueList.
Parameter or variable '@providersToAdd' has an invalid data type.
Implementation as explained here:
-
http://www.simple-talk.com/sql/t-sql-programming/temporary-tables-in-sql-server/
-
http://www.sqlteam.com/article/sql-server-2008-table-valued-parameters
Does anyone have an idea why this happens?
I am pretty sure it is due to creating the procedure in the tempdb space, using CREATE PROCEDURE
#update_AttributeFormel. See this SQL Fiddle where it is working perfectly when the types and the procedure are in the same database.The code is replicated below: