I have a select statement that is used in a gridview via a stored procedure:
SELECT * FROM T_Computer WHERE (ISTag LIKE '%' + @ISTag + '%') AND Status <> 'Trashed' AND Status <> 'Sold' AND Status <> 'Stored'
The @ISTag, an nchar is determined by a textbox value, if the textbox is empty I have the default value set to %, which in my mind should essentially negate that part of the where clause and return all of the rows except the ones negated by the Status column. Instead it isn't returning anything. If I remove the "+ @ISTag +" it does what I want.
Basically three %'s return nothing, but 2 %'s return what I want. How should I fix this?