CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: SQL syntax

  1. #1
    Join Date
    Oct 1999
    Location
    Northern Virginia
    Posts
    124

    SQL syntax

    I am getting a syntax error in the FROM clause error and for the life of me I cannot see what is wrong with my SQL string. Here it is:

    SQLStmt = "SELECT " & strTableName & ".* INTO [CLEARANCE] FROM " & strTableName




    strTableName is the name of a table that I extracted from TableDef earlier in the module. Am I blind? :-)


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: SQL syntax

    Try this

    SQLStmt = "SELECT * INTO NewTable FROM " & strTableName

    or if you need to insert into different table

    SQLStmt = "INSERT INTO NewTable SELECT * FROM " & strTableName



    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Oct 1999
    Location
    Northern Virginia
    Posts
    124

    Re: SQL syntax

    No, not quite what I was looking for. I just happened to stumble upon the solution just a couple minutes ago. I had forgotten to mention that the table name represented by strTableName has two forward slashes in it. I thought there was no problem with that because in an earlier procedure I was using the reverse process and putting the table name (that contains slashes) in an INTO clause and VB did not complain one bit, but for some quirky reason it does complain when those same table names are in the FROM clause. So what I had to do is surround my table name variable with backquotes (NOT single quotes, but the quote found on the tilde (˜) key) like this:

    SQLStmt = "SELECT " & strTableName & ".* INTO [CLEARANCE] FROM `" & strTableName & "`"
    dbClearance.Execute (SQLStmt)





  4. #4
    Join Date
    Apr 2001
    Location
    Georgia
    Posts
    3

    Re: SQL syntax

    this sounds like an "INSERT" statment


Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured