Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Query

Status
Not open for further replies.

Tailgun

Technical User
Mar 30, 2002
417
US
I know this will slow the query down to a crawl but the boss want to search a table (all Columns) for anything that is like what the user types into a textbox. Can anyone help with what to replace the ????? with. I just put the ???? there to explain I don't know what to use in that part of the query, or should the query be written differently ? The results are shown in a VB DataGrid. I'm sure this is a stupid question but I've only been working with SQL for a very short time.

"SELECT * FROM tblClaim WHERE ????????? LIKE '%" & txtClaimDB.Text & "%'"

thanks for any and all help.
 
Well, you could do this :

SELECT *
FROM tblClaim
WHERE Column1 LIKE '%srchvalue%'
OR Column2 LIKE '%srchvalue%'
OR Column3 LIKE '%srchvalue%'
...

I doubt if there is any other easy option other than hard coding all column names there. Make sure you include only character columns (char/varchar/nchar/nvarchar/text).

Hope this helps
Gana
 
thanks Gana :)

I was hoping there would be an easier way. just my luck,
the table has alot of columns so I'm not sure the boss can have what he wants

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top