Question

  Asked: Feb 8 2008   7:12 PM GMT
  Asked by: MAB TRIBEFAN


'm trying to verify that a SQL DATABASE is empty ,


Data/Application Integration, SQL, Database


I am modifying a VB program that is taking ALL the tables from an ACCESS Database and converting them to a SQL DATABASE.
They VB Program opens the SQL DATABASE, but I want to verify the database is completely empty. Is there a function or call that can be added to the code??

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0



There's no function, but you can query the system and see what's in there.

SQL 7/2000
To look and see if there are any tables in the database.
SELECT *
FROM sysobjects
WHERE xtype = 'U'
and name <> 'dtproperties' /*This table is used for the database diagrams, so you don't want to delete it.*/


To look and see if there are any views in the database.
SELECT *
FROM sysobjects
WHERE Xtype = 'V'


To look and see if there are any procedures in the database.
SELECT *
FROM sysobjects
WHERE xtype = 'P'


SQL 2005+
To look and see if there are any tables in the database.
SELECT *
FROM sys.tables


To look and see if there are any views in the database.
SELECT *
FROM sys.views


To look and see if there are any procedures in the database.
SELECT *
FROM sys.procedures
  • AddThis Social Bookmark Button

Browse more Questions and Answers on DataManagement, Development and Database.

Looking for relevant DataManagement Whitepapers? Visit the SearchDataManagement.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register

Mrdenny  |   Feb 8 2008  7:42PM GMT

Check out my SQL Server blog “SQL Server with Mr Denny” for more SQL Server information.