Delete table in MSSQL dbWe can delete a table from MSSQL database by using DROP table command ( Query ) . Let us try with simple example first. While executing this command in any .asp page we must ensure that we have connected to MSSQL database with proper userid and password. We are not providing the connection string and associated code here but you can download the total code by downloading the file at the end of the page.
You can test this query in your Microsoft SQL Server Management Studio
The above command will delete the table member from the database. What happens we run the same query again. You will get an error message like this
The reason is simple , we have already deleted the table so we can't delete again. Then how to check the existence of the table before deleting to avoid the error message ? We will modify our query and add the command IF EXISTS to it.
We can also search INFORMATION_SCHEMA to check if table exists or not.
Be the first to post comment on this article :