wildcard character - MS-SQL

Results 1 to 2 of 2

Thread: wildcard character - MS-SQL

  1. #1
    Join Date
    Dec 1969

    Default wildcard character - MS-SQL

    I&#039;ve to search records based on keywords typed in by user. MS-SQL database.<BR><BR>My code looks like below. (code was written with the help of reply posted to my question sometime back.) Code worked on Access db. I need it to change it for MS- SQL. I tried changing the % with $, but it is not showing result. I&#039;ve tried to search with a word which is used in many products, however it gives me EOF.<BR><BR><BR>strSearch = trim(request.querystring("keywords"))<BR>ncur = request.querystring("ncurpage")<BR>dim ncurpage, rowcount<BR>ncurpage = trim(ncur)<BR>if ncurpage = "" then ncurpage = 1<BR>set rsp = server.Createobject("ADODB.Recordset")<BR>rsp.curs ortype=adopenstatic<BR>showrec = 12<BR>rsp.pagesize = showrec <BR><BR><BR> MySearchList = split(strSearch, " ") <BR> strSQL = "SELECT * FROM products WHERE " <BR> For I = 0 to Ubound(MySearchList) <BR> strSQL = strSQL & " ProdName LIKE &#039;$" & MySearchList(I) & "$&#039;" <BR> Next <BR> strSQL = strSQL & " ORDER BY ProdName asc"<BR> rsp.open strSQL , conn<BR><BR> if rsp.eof then<BR> response.write "<BR><BR>There are no products found. Please refresh your search.<BR><BR><BR><BR><BR>"<BR> else<BR> DO WHATVER<BR> end if<BR><BR>================<BR><BR>On repsonse writing the SQL it shows - <BR><BR>SELECT * FROM products WHERE ProdName LIKE &#039;$ladies$&#039; ORDER BY ProdName asc <BR> <BR>Thanks in advance

  2. #2
    Join Date
    Dec 1969

    Default RE: Checked previous posts..

    and found answer to my question. I used % in SQL instead of $, it works!<BR><BR>For some odd reason I thought, that works with Acess and no MS-SQL..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

More ASP Resources

-- ASP Articles
-- ASP.NET Information
-- 4Guys ASP F.A.Q.
-- ASPFAQs.com
-- ASP Coding Tips
-- Related Web Technologies
-- User Tips!!
-- JavaScripts

Development Centers
-- HTML5 Development Center
-- Windows Mobile Development Center
-- Android Development Center
-- Cloud Development Project Center

Development Technology
Check out these sites for more articles, tutorials, FAQs, discussions, and code!
-- CodeGuru.com
-- VBForums.com
-- DevX.com
-- Developer.com
-- HTMLGoodies