I’m using a user defined table type to pass into my stored proc.
I’ve had cause to change the table type to add an extra column, and now I get the error:
The parameter “@MyParam” is not the same type as the type it was
created with. Drop and recreate the module using a two-part name for
the type, or use sp_refreshsqlmodule to refresh its parameters
metadata.
when calling the proc from my .net code.
I am adding the param value to my command like so:
var param = _command.Parameters.AddWithValue("@MyParam" , myTypedDataTable)
param.SqlDbType = SqlDbType.Structured;
where myTypedDataTable has been updated to contain the new column.
I have tried dropping and recreating the stored proc that is called, as well as dropping and recreating the User Defined Table.
I have also (thanks to Google) tried to use sys.sp_refreshsqlmodule on my Stored Proc and User Defined Table (It did not work however, on the User Defined Table, giving me the error: “Could not find object ‘[myUserDefinedTable]’ or you do not have permission.”, I beleieve this may be due to sys.sp_refreshsqlmodule not being able to work on user defined tables?)
I think I am probably missing something basic here, but can’t see what?
I have found the error. There was another stored proc which relied on the user defined table which needed to be dropped and recreated. I’m surprised that this was missed, as when I tried to drop the user defined table first time around, It did not let me as the SP mentioned above referenced it (I had to drop the SP to remove the dependency, then drop the User Defined Table, and then recreate them both), yet it did not complain about a dependency for the newly found SP?