s

mssql exception Operand type clash dbo.type_name1 is incompatible with dbo.type_name2 edit button Edit

author
Murugan Andezuthu Dharmaratnam | calendar 24 September 2020 | 2074

Conversion failed when converting the nvarchar value 'Heat the oil in a pan' to data type int.\r\nThe data for table-valued parameter \"@RecipeDirections\" doesn't conform to the table type of the parameter. SQL Server error is: 245, state: 1\r\nThe statement has been terminated.

mssql exception Operand type clash: dbo.type_name1 is incompatible with dbo.type_name2. I got this error while I was calling the stored procedure by passing a list of objects to a custom table type in the stored procedure. I had two lists which I had to pass to the stored procedure. The problem with my SQL script was that by mistake I was using the same table type for both parameter. @RecipeDirections [type_recipeingredients] READONLY, @RecipeIngredients [type_recipeingredients] READONLY . I corrected it by passing the correct table types

CREATE PROCEDURE [dbo].[sp_name]
	@RecipeDirections [type_recipedirections] READONLY,
	@RecipeIngredients [type_recipeingredients] READONLY,
	@RecipeId uniqueidentifier
AS