When using a parameter to an integer ID column, you need to break the statement apart so that the parameter stands apart from the wildcard characters:
string sql = @"SELECT * FROM myTable WHERE iId like '[%]' + @iId + '[%]'";
However, that same syntax will not work if you are using a varchar column. Instead, you need to embed the wildcard characters directly into the paramter's value:
string sql = @"SELECT * FROM myTable WHERE vcDesc like @iId"; cmd.Parameters.Add(new SqlParameter("@vcDesc", "%" + desc + "%"));
The second syntax works in both cases, so it probably just makes sense to use that everywhere and not worry
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.