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

5 pts.
Tags:
Data/Application Integration
Database
SQL
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??

Answer Wiki

Thanks. We'll let you know when a new response is added.

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.
<pre>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.*/
</pre>

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

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

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

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

To look and see if there are any procedures in the database.
<pre>SELECT *
FROM sys.procedures</pre>

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: