Re: SqlConnection question

From: Jerry Pisk (jerryiii_at_hotmail.com)
Date: 04/21/04


Date: Tue, 20 Apr 2004 20:14:32 -0700

Not exactly, if you supply a name that's not a table but a stored procedure
you will still get 1. If there are multiple tables with the same name you
will get more than 1, even though non eof those tables is the one you want.
To check for a specific table you need to execute:

SELECT * FROM [dbo].[sysobjects] WHERE id =
OBJECT_ID(N'[owner].[table_name]') AND OBJECTPROPERTY(id, N'IsUserTable') =
1

and either use this as an EXISTS condition or do SELECT COUNT(*) or just
check the recordset for a record.

Jerry

"Senguttuvan" <cheran_76@yahoo.com> wrote in message
news:0C9A0822-51BA-48C1-8905-86E30B2BCFA7@microsoft.com...
> Hi Sam,
>
> The following query will return 1 if the table exist in the
database. Just replace the 'Table Name' with the table name you want to
check for the existence.
>
> select count(*) from SYSOBJECTS where name = 'Table Name'
>
> Thanks,
> Senguttuvan
>
>
> ----- Sam Johnson wrote: -----
>
> Hi,
>
> how can I test if a specific table on an SQL- Server (that I'm
connected to) exists or not?
>
> Thanks
> Sam



Relevant Pages

  • Time out issues Views/stored procedures
    ... I have a stored procedure that has multiple select statements, ... statement is giving me a count on a specific recordset and than writes the ... It doesn't time out in query analyizer. ...
    (microsoft.public.access.adp.sqlserver)
  • Re: SqlDataSource and multiple recordsets
    ... A dataset can be filled with multiple tables from your stored procedure, ... If you want a SqlDataSource, you would need one for each table. ... Could I use the sqldatasource with stored-procedure to return multiple recordset? ...
    (microsoft.public.dotnet.framework.aspnet)
  • Passing ADO Recordset to Oracle Stored Procedure
    ... Can we pass a recordset from a VB application to a Stored Procedure ... written in Oralce. ... Sam ...
    (microsoft.public.data.ado)
  • Passing ADO Recordset to Oracle Stored Procedure
    ... Can we pass a recordset from a VB application to a Stored Procedure ... written in Oralce. ... Sam ...
    (microsoft.public.vb.database)
  • Re: Copy Data from one ADO recordset to Another ...
    ... recordset created off a Stored Procedure that contains multiple tables, ... hence the recordset is not updatable. ... results from the Stored Procedure. ... > Senior Technical Consultant ...
    (microsoft.public.vb.general.discussion)