How to Drop Database by using T-SQL or GUI - SQL Server / T-SQL Tutorial Part 25
How to Drop Database by using T-SQL or GUI - SQL Server / T-SQL Tutorial Link to post for scripts http://www.techbrothersit.com/2016/02/how-to-drop-database-by-using-tsql-and.html Scenario: You are working as Database developer in Health Insurance company, You need to generate script to drop database that can be used in different environments such as QA, UAT and Production. Solution: There are multiple ways to drop the database in SQL Server. You can use GUI part of SSMS to drop database. By using GUI: Right Click on the database that you would like to drop and then hit Delete. check the checkbox Close existing connections. This will close any existing connections, if you don't check this, the drop might fail if there are open connections to database. Use TSQL To Drop Database in SQL Server: At this point you can hit Script button in above window to generate script so you can use anytime you like. Once you hit Script and open in new window. Below Script will be create. USE [master] GO ALTER DATABASE [TechBrothersIT] SET SINGLE_USER WITH ROLLBACK IMMEDIATE GO USE [master] GO DROP DATABASE [TechBrothersIT] GO The first part of script will set the database to Single User mode and rollback any open transactions immediately. Second Part of script will drop the database. Check out our website for Different SQL Server, MSBI tutorials and interview questions such as SQL Server Reporting Services(SSRS) Tutorial SQL Server Integration Services(SSIS) Tutorial SQL Server DBA Tutorial SQL Server / TSQL Tutorial ( Beginner to Advance) http://www.techbrothersit.com/
Download
0 formatsNo download links available.