title: Sql select query using like
body: <p>I am trying to run this code</p>
  
  <pre><code> public long getTopicCountWithTag(String tag)
      {
          long count;
          query = " SELECT count(*) FROM [DB_us2].[dbo].[discns] where tags like '%@tags%'";
          try
          {
              com = new SqlCommand(query, con);
              com.Parameters.AddWithValue("@tags", tag);
              con.Open();          
              sdr = com.ExecuteReader();
              sdr.Read();
              count= sdr.GetInt32(0);
  
          }
          catch (Exception e)
          {
              count = -1;
              throw e;
          }
          finally
          {
              con.Close();
          }
          return count;
      }
  </code></pre>
  
  <p>its giving output <code>0</code> . So i try figure out what is the problem and run sample query on  management studio but output is different its giving <code>1</code>. After trying all permutation combination, i think problem is with this statement <code>com.Parameters.AddWithValue("@tags", tag);</code> might be possible <code>@tags</code> is not replaced in query.</p>