Like 变量查询时注意,在变量上加上格式化字符,如:where [Cust_Item_No]like '%'+RTrim(@item_No)+'%'";

 
例如:
     public string[] AutoCust_Item_No(string item_No)
        {
            string sql = "SELECT top 1 [Cust_Item_No]  FROM [SO_detail]where [Cust_Item_No]like '%'+RTrim(@item_No)+'%'";
            SqlParameter[] Parameter= new SqlParameter[1];
            Parameter[0] = new SqlParameter("@item_No", SqlDbType.VarChar, 50);
            Parameter[0].Value = item_No.Trim();
            DataTable rs = SqlHelper.ExecuteDataTable(SqlHelper.CONN_STR, CommandType.Text, sql,parameter);

        }

Like 变量查询时注意,在变量上加上格式化字符,如:where [Cust_Item_No]like '%'+RTrim(@item_No)+'%'";

你可能感兴趣的:(Like 变量查询时注意,在变量上加上格式化字符,如:where [Cust_Item_No]like '%'+RTrim(@item_No)+'%'";)