All Type Coding

Search Here

How to drop a table from database in sql server.?

Drop Command
                                                 The SQL DROP TABLE statement is used to remove a table  and all  data, indexes, triggers, constraints, and permission specifications for that table.
Syntax of Drop command
                                         Drop Table Table_Name
Now we'll learn how to drop table from database step by step

step1.Here I have already created table tblEmployee1









































step2. Now we'll execute the Drop command after executing the drop command the table will be drop from database.













Now again  execute the select command.















In above image .I execute the select command I got an error "Invalid object name,tblEmployee1" Because The table had been deleted or drop from database .You can seen the above top first image in  left side tblEmployee1 table is there .before executing the drop command tblEmployee1 table was there .Thus we can drop a table.
We can drop more than one table using drop command at the same time like
         Drop Table table_Name1,table_Nmae2,......;
we can drop index and database also with drop command
Drop Index
                    DROP INDEX Index_Product_1
                    
ON dbo.table_Name; 
OR
                    ALTER TABLE Table_Nmae DROP INDEX                                                           Index_Name;

For database 


                    Drop Database database_name

No comments :

Post a Comment