Re: SqlConnection question
From: Jerry Pisk (jerryiii_at_hotmail.com)
Date: 04/21/04
- Next message: Jeerakarn W.: "Re: Bulk Inserts - High Speed"
- Previous message: Fool: "Re: Find Method - How to compare only a part of the string?"
- In reply to: Senguttuvan: "RE: SqlConnection question"
- Next in thread: Val Mazur: "Re: SqlConnection question"
- Messages sorted by: [ date ] [ thread ]
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
- Next message: Jeerakarn W.: "Re: Bulk Inserts - High Speed"
- Previous message: Fool: "Re: Find Method - How to compare only a part of the string?"
- In reply to: Senguttuvan: "RE: SqlConnection question"
- Next in thread: Val Mazur: "Re: SqlConnection question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|