How to create table in sql server 2005?


In this article, I have mentioned syntax of sql server 2005. It will be helpful for SQL server 2005 beginners. Data Manipulation Language (DML) is easy to use and understand.

Step 1: Create new database 'employeeDb'.
Step 2: Execute following code to create table 'employeeData'.


USE [employeeDb]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[employeeData](
[empid] [int] NOT NULL,
[empname] [varchar](50) COLLATE Latin1_General_CI_AI NULL ,
[bonusvalue] [int] NULL,
[joiningdate] [datetime] NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF

Step 3: Insert few records into table using INSERT command and retrieve data from the table using following code:

SELECT [empid]
,[empname]
,[bonusvalue]
,[joiningdate]
FROM [employeeDb].[dbo].[employeeData]


Comments

Author: Imenso Software13 May 2013 Member Level: Bronze   Points : 0

Thanks for good and clean codes you are sharing with us.



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: