Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
guyinkalamazoo
Starting Member
1 Post |
Posted - 2005-12-12 : 11:34:44
|
| I am not totally new to SQL server, but I have a question regarding a SQL statement.I have the following: SELECT SORT, NAME1, NAME2, PAID, WORKINFO FROM CASHDTL WHERE (SORT=?). This is a statement that returns data from an AS400. My question is about the parameter. I have users that would like to type in a keyword and then search each field if it includes their search string. In researching, I can use the LIKE statement instead of "=". However, what would the proper syntax be? It is not allowing me to do WHERE (SORT='%?%') but if I replace the '?' with text it does work just fine.I am using a dataset built into an ASP .Net page.Thanks for any information. |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2005-12-12 : 11:58:03
|
| If ur SQL Statement is in client side, create it using VB in a manner once created to have the following syntaxSelect a,b,c,d from MyTbl where F1 like '%UrSrchStr%'ie in VB, u can do as follows:sSQL = " Select a,b,c,d from MyTbl where F1 like '%" & txtSrch.Text & "%'"Then Use ADO to pass query the DBor else if the query is in Database as a stored procedure, u can pass it as a parameter (Of course, u need to write the procedure so as to accept the parameter) and create the query to follow the above syntax. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-12-13 : 00:12:16
|
| >>WHERE (SORT='%?%') That should be WHERE (SORT Like '%?%')MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|