Dealing with spaces in SQL

Results 1 to 3 of 3

Thread: Dealing with spaces in SQL

  1. #1
    Adrian Guest

    Default Dealing with spaces in SQL

    How do I run a query off of a Querystring that has spaces in it. i.e.: if a page is default.asp?User 1=value and the SQL is: "SELECT * FROM table WHERE" & Request.QueryString() & "<BR><BR>I am getting the feeling that the SQL is trying to find:<BR> User%201=value

  2. #2
    Shawn Clabough Guest

    Default RE: Dealing with spaces in SQL

    I have not used spaces in the variable name, but have used them in the value I&#039m passing. I just tested both &#039default.asp?variable=first+name&#039 and &#039default.asp?variable=first%20name&#039 in the URL of my page and both worked when the code was searching the database for &#039first name&#039.

  3. #3
    Join Date
    Dec 1969
    Posts
    2,849

    Default RE: Dealing with spaces in SQL

    You can Replace all %20&#039s with spaces like so:<BR><BR>SQL = "SELECT * FROM table WHERE " & Replace(Request.QueryString(),"%20"," ")<BR><BR>To learn more about the replace statement, be sure to check out:<BR>http://help.activeserverpages.com/iishelp/VBScript/htm/vbs170.htm<BR><BR>Have a great day!

Posting Permissions

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