Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ODBC - how to check if table already exist, if not create table..

Posted on 2000-03-28
2
Medium Priority
?
735 Views
Last Modified: 2013-11-20
hi guys,

would like to know how to check if a table already exists in the database, and if not then I would like to create the table...

I am using VC6(MFC with ODBC Apis) and SQL Server 7.0...can anybody guide me with some sample code..?

Thanks!

0
Comment
Question by:Haho
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
mikeblas earned 225 total points
ID: 2666047
If you know the database you're talking to, then just use the system catalog. For instance, if you're using SQL Server, just check the SYSOBJECTS table for your table.

If you don't know the database, then try executing a meaningless query. Like:

   UPDATE YourTable
     SET YourTable.Column = YourTable.Colum
  WHERE 1 = 0

If the error you get back is about the table not being found, then you know the table doesn't exist.  If you get no error back, you know the table exists.

..B ekiM
0
 
LVL 3

Expert Comment

by:V_Bapat
ID: 2666136
Hi Haho
Use ::SqlTables() to get the list of all tables in the database.
For privileges for a table call ::SqlTablePrivileges()

Vicky
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question