I keep getting an error that says:
[SqlException (0x80131904): Must declare the scalar variable "@DeviceSearch".]
Even though the value is being passed into the Stored Procedure. Here is the SQL Trace:
exec InventorySearch @FieldName=N'Value',@TableName=N'AssetTag',@SearchTerm=N'00002730',@DeviceSearch=1
Here is the variable declaration in the Stored Procedure and also the line that is using it:
@DeviceSearch nvarchar(50),
@FieldName AS nvarchar(50),
@TableName AS nvarchar(50),
@SearchTerm nvarchar(50)
WHERE (@DeviceSearch = 1 and LogicallyDeleted = 0 and '+ @TableName+ '.'+ @FieldName+
' like ''%@SearchTerm%'')
Can anyone see what I need to do to correct this?