Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Serbia and Montenegro (Yugoslavia)
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Delete Query Syntax Error (VB6, SQL Server 2K)

    The error reads Error near "*". Here is the code it is trying to execute:

    CN.Execute ("DELETE * FROM tblEmpl WHERE FullName = '" + txtLastName.Text + ", " + txtFirstName.Text + "'")

    I replaced the & with +'s, which I knew SQL Server was particular about. What is up with the * ?

  2. #2
    Star Lounger
    Join Date
    Nov 2001
    Location
    Illinois, USA
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete Query Syntax Error (VB6, SQL Server 2K)

    Mike, I think what you want is DELETE FROM, omitting the *.

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Delete Query Syntax Error (VB6, SQL Server 2K)

    Dottie's right, Mike. The asterisk is not recognized as valid in that construction--one of the various pitfalls in moving from Access/Jet SQL to SQL Server.
    Charlotte

  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Serbia and Montenegro (Yugoslavia)
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete Query Syntax Error (VB6, SQL Server 2K)

    Dottie, Charlotte - thanks! This worked perfectly (and so much faster on the SQL server).

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Serbia and Montenegro (Yugoslavia)
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete Query Syntax Error (VB6, SQL Server 2K)

    Okay, I'm in an Access 2002 ADP file trying to delete all records out of one of my tables. I'm trying:

    DELETE FROM dbo.tblHistory

    And it is giving me the same error "Near Delete" thing. I've also tried the * and that didn't work either. Now, how do I delete from within an ADP?

    God, I'm sure glad we came up with a STANDARDIZED query language.

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Delete Query Syntax in an ADP

    Try creating a stored procedure (using the new button) like this:
    <hr>Create Procedure "StoredProcedure1"
    As
    set nocount on
    DELETE FROM dbo.tblHistory
    return <hr>
    Then run it.
    Charlotte

Posting Permissions

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