Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 does table exist code

Author  Topic 

rdavis101
Starting Member

1 Post

Posted - 2006-07-27 : 19:35:23
SO I'm looking at the code on the net for determining whether a table exists, and I'm thinking this is a common enough issue that there's a single statement for it...but the code the author supplied is below. Comments?

global $exists;
$exists = 0;
$dataset = mysql_query('SHOW TABLES') ;
while( $row = mysql_fetch_row($dataset) )
{
if ( $row[0] == "mos_tbd_tags" ) {
$exists = 1;
break;
}
}

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2006-07-27 : 19:52:05
you may want to go and ask your question at http://dbforums.com since they have a dedicated MySQL forum. This site is really a SQL Server specific site and you probably won't see many responses to your question.



-ec
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-07-28 : 11:46:15
or try at www.MySQL.com

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-07-28 : 13:46:50
Or if it's sql server (which is what this site is for)

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tablename]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam
Go to Top of Page
   

- Advertisement -