Learning Horizon | For Learners

ASP.NET, SQL SERVER, JQUERY,JAVASCRIPT, WEBSPHERE

Saturday 6 April 2013

Create Database in SQL Server

As a database learner or In your first database lab class you may be asked to create database and tables in SQL Server. Here I am going to tell you the method of creating your first database and table in SQL Server.

Create Database

Open your SQL Server Management Studio(SSMS) and Press ctrl + n to open new query window. Type below query in your query window and execute it to create your first database.

Query Syntax :

 
  	create database <your_database_name>
 

Example :

 
	create database DEMODB

Create Table

To create your first table in above mentioned database "DEMODB" first you need to select the database you created with above sql query. After that you can make table with the help of create table command.

Query Syntax :


    use <database_name>
    
    create table <your_table_name>
    ( 
    your_column_name1 data_type,
    your_column_name2 data_type,
    your_column_name2 data_type
    )
 

Example :

 
  
  create table customer
  (
  customer_id bigint, 
  customer_name varchar(100),
  customer_dob datetime
  )
  

  

No comments:

Post a Comment

Please do not enter spam links.