Saturday, May 11, 2019

How to Create and Drop Database in SQL server

Create Database:

There are several ways to create and drop a database in SQL servers using GUI or TSQL. Here I will show in both ways how to do it.

1)GUI - SSMS

Connect to SQL server using SSMS


Right Click on Database and click on "New database"

Provide the DatabaseName

also, you have the options to configure the database
->Restrict the DB size(Datafile and Logfile size)

->Set the DB owner

->Set the Recovery model
->Set the compatibility mode
->Set the collation


Click OK

Refresh the Database and you can see TESTDB created


2)T-SQL

Connect to SQL server using SSMS
Click on New Query and query to create new DB is

use [master]
go
Create Database [DatabaseName] -- Replace the [DatabaseName] with TESTDB
go

and click Execute





Drop Database:

1)GUI- SSMS

Connect to SQL server using SSMS

Expand Database section

Select the Database and right click
click on Delete

Click OK



2)T-SQL

Connect to SQL server using SSMS
Click on New Query and query to drop DB is

use [master]
go
Drop Database [DatabaseName] -- Replace the [DatabaseName] with TESTDB
go

and click Execute

No comments:

Post a Comment