0

I was going to check if a temp table exists and delete the it,since "the temptable already exists" arises if you want to perform another operation.
Here's the code i used five statements but it says syntax error in drop table or drop index statement.
Any help would be appreciated.

"DROP TABLE IF EXISTS LIKE 'prtempTable%'"
"DROP TABLE IF EXISTS LIKE '%prtempTable%'"
"DROP TABLE IF EXISTS WHERE TABLE LIKE 'prtempTable%'"
"DROP TABLE LIKE 'prtempTable%'"
"DROP TABLE LIKE '%prtempTable%'"
2
Contributors
6
Replies
26
Views
3 Years
Discussion Span
Last Post by Nebil
0

It doesn't work,since it's for sql server db.Is there another way to solve it?

0

How about just putting the delete code in a Try-Catch block and seeing what error occurs if the table does not exist? That will tell you what error to ignore.

0

I used this sub procedure and it worked fine.

On Error GoTo ErrorHandler
        Dim str As String
        str = "DROP TABLE ptempTable"
        ExecSQL(str)
        Exit Sub
ErrorHandler:
        If Err.Number = 7874 Then
            Resume Next
        End If

Thanks by the way

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.