title: t-sql command parameter wildcard
body: <p>I've read numerous similar questions, but the answers simply didn't work. Running this function in sql <code>select * from HelloRow('o')</code> returns no rows. Running <code>HelloRow('one')</code> returns the row with name "one". The fillrow method doesn't do anything (just reads the strings).</p>
  
  <pre><code>[Microsoft.SqlServer.Server.SqlFunction(FillRowMethodName = "HelloFillRow", DataAccess = DataAccessKind.Read, TableDefinition="message nchar(20)")]
  public static IEnumerable HelloQuery(SqlString like)
  {
      ArrayList resultCollection = new ArrayList();
  
      using (SqlConnection connection = new SqlConnection("context connection=true"))
      {
          connection.Open();
  
          using (SqlCommand select = new SqlCommand(
              "select name from test where name like @par"
              , connection))
          {
              select.Parameters.Add("par", SqlDbType.NChar, 10).Value = like + "%";
              using (SqlDataReader selectReader = select.ExecuteReader())
              {
                  while (selectReader.Read())
                  {
                      SqlString nextName = selectReader.GetString(0);
                      resultCollection.Add(nextName.ToString());
                  }
              }
          }
      }
      return resultCollection;
  }
  </code></pre>