Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 To drop all tables from a database

Author  Topic 

arthiasha
Starting Member

40 Posts

Posted - 2012-12-14 : 00:56:21
Hi,
I'm a beginner in sql server...
I need a query to drop all tables and stored procedures from a database so that i create a new tables and sp in MSSQL 2008 without affecting other databases.

thanks in advance...

RajanThan
Starting Member

7 Posts

Posted - 2012-12-14 : 01:06:41
Hi,

Delete all the table by using the below query,

EXEC sp_MSforeachtable @command1 = "DROP TABLE ?"



Rajan
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2012-12-14 : 01:15:54
Follow these steps:

1)Right Click on database on which you have tables and SP's
2) Tasks --> Generate Scripts --> next --> select specific database objects (tables and SPs) --> Click on Advanced tab --> Choose Script DROP from Script DROP and CREATE option --> Select 'Save to new Query Window' --> OK
3) Then run this script (to drop table and SPs)

--
Chandu
Go to Top of Page

arthiasha
Starting Member

40 Posts

Posted - 2012-12-14 : 01:53:18
Thanks a lot....
I worked out :)
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2012-12-14 : 01:54:36
quote:
Originally posted by arthiasha

Thanks a lot....
I worked out :)


Welcome

--
Chandu
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-12-14 : 01:58:30
Easiest option is initial suggestion rather than scripting out and then reapplying

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -