Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 28th, 2008, 05:55 PM
saatreddy saatreddy is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Posts: 11 saatreddy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 27 m 27 sec
Reputation Power: 0
SQL statement to check if a table exists

Hi,

I want to know if there is a sql statement to check if a table exists in database. I am using ms acess. I used

[CODE}
statement.executeQuery("select count(1) from MSysObjects where name='abc' and type=1");
[CODE]

When I execute this in database it executes fine, but when i execute thus from java class I get
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Record(s) cannot be read; no read permission on 'MSysObjects'.

Is there another way I can check if a table exits?

Thanks

Reply With Quote
  #2  
Old April 1st, 2008, 03:35 AM
Annie79's Avatar
Annie79 Annie79 is offline
Meow Black Belt
Click here for more information
 
Join Date: Oct 2005
Location: Beaverton OR
Posts: 913 Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)  Folding Points: 49426 Folding Title: Beginner FolderFolding Points: 49426 Folding Title: Beginner FolderFolding Points: 49426 Folding Title: Beginner Folder
Time spent in forums: 4 Weeks 8 h 7 m 11 sec
Reputation Power: 433
I doubt if checking for existence of the table is going to help. The error message indicates a permission problem, you should get permissions on the table.
__________________

Reply With Quote
  #3  
Old April 5th, 2008, 08:01 AM
gdrav gdrav is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Location: ohio
Posts: 23 gdrav User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 6 m 8 sec
Reputation Power: 0
if object_id('database..table1') is not null
This may get around your permission issue with sysobjects

Hope this helps
-gdrav

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > SQL statement to check if a table exists


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway