Codechef4u is a community for computer professionals,by computer professionals,just like you; who loves sharing and helping each others,Join them
Share your post

How to create new Database in Sql server

To create new database in SQL Server:

   To create a database Using T-SQL:
·       Connect to the Database Engine.
·       From the Standard bar, click New Query.
·       Copy and paste the following example into the query window and click Execute.


USE [master]
/****** Object: Database [dbCodeChef4u] Script Date: 04/19/2015 15:56:53 ******/
( NAME = N'dbCodeChef4u', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\dbCodeChef4u.mdf' , SIZE = 2048KB, MAXSIZE = UNLIMITED, FILEGROWTH= 1024KB )
( NAME = N'dbCodeChef4u_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\dbCodeChef4u_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)


 Create a database using SQL Server management studio:


 Default steps:

1.       In Object Explorer, connect to an instance of the SQL Server Database Engine and then expand that instance.


2.       Right-click Databases, and then click New Database.

3.         In New Database, enter a database name.

4.       To create the database by accepting all default values, click OK


5.       Check Created database:

  Optional steps:

a.       To change the owner name, click (…) to select another owner.

b.        To change the default values of the primary data and transaction log files, in the Database files grid, click the   appropriate cell and enter the new value. For more information, see Add Data or Log Files to a Database.

c.        To change the collation of the database, select the Options page, and then select a collation from the list.