Sql syntax error

Results 1 to 2 of 2

Thread: Sql syntax error

  1. #1
    Join Date
    Dec 1969

    Default Sql syntax error

    Hi I&#039;m trying to retrive some info from a database using the sql statement below<BR><BR>&#060;% Indice = (RSSharename("Indice"))<BR><BR><BR>set RSshareprice = conn.Execute("select * from "& Indice &"<BR>where "_<BR> <BR>& "Epic = &#039;"& UpperCaseString &"&#039; ")<BR><BR><BR>Response.Write(RSshareprice("Epic")) %&#062;<BR><BR>I&#039;ll explain what I&#039;m trying to do. <BR><BR>First I&#039;m setting the variable Indice to the result of a previous sql statement, ie the indice field in a seperate table.<BR><BR>Then I&#039;m retrieving information from the table specified by the Indice variable.<BR><BR>From this table I&#039;m trying to return the row where the feild Epic is equal to a variable called UpperCaseString.<BR><BR>My big problem is the syntax. <BR>The field Epic consists of a code such as BA.L which is encased in quotes such as "BA.L". So i need to add the quotes in the sql string.<BR><BR>The string I need to produce is<BR><BR>select * from ftse100 where epic = "BA.L"<BR><BR>Where in this case indice = ftse 100 and UpperCaseString = BA.L<BR><BR>If you can help I&#039;d be grateful<BR>cheers Mal<BR>

  2. #2
    DaveL Guest

    Default RE: Sql syntax error

    You seem to have the syntax right at one point:<BR><BR>select * from &#039;"& Indice & "&#039; where " & "Epic = &#039;" & UpperCaseString &"&#039; "<BR><BR>This will work if UppercaseString has quotes or not - assuming that it matches the database field, i.e the field has quotes. If the problem is removing quotes from fields there are all sorts of string manipulation functions to remove them, e.g. Left,Right,Mid etc

Posting Permissions

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