Check to see if a table exists

From: Kirk (Kirk_at_discussions.microsoft.com)
Date: 06/22/04


Date: Tue, 22 Jun 2004 09:16:01 -0700

I am running Sql Server 7.0 and I am using a store procedure to drop a global temp table if it exists.

Currently, it looks like this:

if object_id('##Table') is null
        print 'True'
        else
        print 'False'
        Drop Table ##tmpTable

It works fine through Query Analyzer, but when I try to execute this code through ASP code, I get the following error:

Microsoft OLE DB Provider for SQL Server error '80040e09' With the statement printing out TRUE that the table doesn't exist. And if doesn't exist, it should continue on and create the table as instructed.

Any ideas as to what I am doing wrong? Is there a better way to check as to whether or not a table exists? Any help would be appreciated.

Thanks.

Kirk



Relevant Pages

  • Re: Check if a table exists
    ... You could set this up as a stored procedure, ... through ASP code, ... > Microsoft OLE DB Provider for SQL Server error '80040e09' With the ...
    (microsoft.public.sqlserver.programming)
  • Check if a table exists
    ... I am running Sql Server 7.0 and I am using a store procedure to drop a global temp table if it exists. ... It works fine through Query Analyzer, but when I try to execute this code through ASP code, I get the following error: ... Microsoft OLE DB Provider for SQL Server error '80040e09' With the statement printing out TRUE that the table doesn't exist. ...
    (microsoft.public.sqlserver.programming)
  • Re: Can I set relative paths for linked tables instead of absolute path?
    ... because they want you to use SQL Server as the web ... Shouldn't the asp code just read the stuff straight ... Say, for instance, you had a training database which had both student ... if you wanted to have a query that referenced information that was ...
    (microsoft.public.access.tablesdbdesign)
  • Re: One Insert statement, no looping, creates 2 records?
    ... it's the ASP code getting executed twice. ... SQL Server does not ...
    (microsoft.public.sqlserver.programming)
  • Re: Problems with new security patch....
    ... SQL Server is terminating this process. ... Queries like this had been running since May. ... >> Microsoft OLE DB Provider for SQL Server error '80040e14' ...
    (microsoft.public.sqlserver.security)