I'm programming in vb.net, using vs2005 and sqlserver2005.
I have a pretty simple question, I'm trying to conduct a search on all columns of a given table, the search is driven by a parameter, but I want the search to return rows with "Red dog" if I search for "Red", so I need the wildcard to work, and I don't know how to formulate it. I read online to do the following, but it does not work:
As you can see, I didn't finish out the query on all columns because it wasn't working so far, what am i doing wrong here regarding wildcards? and can I query an sql table and search all columns the way I am doing so now? or does it need to be written differently?
Thank you!
I have a pretty simple question, I'm trying to conduct a search on all columns of a given table, the search is driven by a parameter, but I want the search to return rows with "Red dog" if I search for "Red", so I need the wildcard to work, and I don't know how to formulate it. I read online to do the following, but it does not work:
VB.NET:
SELECT ID, Frame, [Stock Num], Type, [Insurance Code], Mfgr, Color, Size, Cost, Retail, [% Markup], [Qty on Hand], [Reorder Point], [Ordered From], [Qty on Order], [Qty to Order], [Date Ordered], [Date Recieved], [Order Initials], [Recieve Initials], [Date Sold], BarCode FROM dbo.Materials WHERE Frame like '%'+@search+'%' OR [Stock Num] like '%'+@search+'%' OR Type like '%'+@search+'%' or [Insurance Code] like '%'+@search+'%'
As you can see, I didn't finish out the query on all columns because it wasn't working so far, what am i doing wrong here regarding wildcards? and can I query an sql table and search all columns the way I am doing so now? or does it need to be written differently?
Thank you!