stored procedures - SQL wildcards not returning data? -


I have a select statement that is used in gridview through a stored procedure:

  from T_Computer SELECT * where ('%' + ISTag + '%' like ISAG) and position & lt; & Gt; 'Trash' and status & lt; & Gt; 'Sold' and status & lt; & Gt; 'Stored'  @Istag, a nchar is determined by a text box value, if the text box is empty then I have the default value set, which is essentially in my head Part should be refused where all the rows except the refused and the column column will be returned. Instead it is not returning anything if I remove "+ estag +" then it is my wish.  

Actually three% return is nothing, but 2% return which I want. How can I fix this?

I am very worried about this for a start, I have asked these two questions with 13221 rows Run against one table, and get one row in the first example, and about half of them in:

  declare @rad char 30) xofdoc 'rad ='% 'selection count (*) Choose 'docdesc' like 'docdesc' like 'count' from 'xofdoc' like 'docdesc' %%% like '%' + @rad + '%'   second hand However, if I change the declaration of @rad to  varchar  (30) If we put it, then both questions drag all the rows. 

The reason for this is that because it is something that can be done with the data declaration of your @Itag you did not tell how it was declared. This is important because a character is a fixed-length string, which means that for example, (four) for example, if the value of '%' is set to a value, then the value will actually be < Code> '%' . Therefore, the statement evaluates '%' + '%' + '%' : '%%%' . So it only finds the rows which had at least four continuous spaces in the whered column. On the other hand, a varchar is an object with variable length, and the rear location is ignored, which is the result of '%%%' in the above case, and thus the entire column contains the wildcard .

Edit to add : nchar or char, there is no difference in this matter. If you are now using nchar, then change it to nvarchar.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -