Join WhatsApp Channel Join Now
Join WhatsApp Group Join Now
Telegram Channel Join Now

Friday 19 June 2015

How to Create Table in Microsoft SQL Server? Class - 1

In the Freshers Junction Blog, previously we are discussing about Oops Concepts, Aptitude Questions and Technical Interview Questions.

Now we are discussing about “How to Create Table in Microsoft SQL Server”.

To Create Table in SQL Server, syntax is

 Create table <table_name> (column name data type, column name Data type)

Example:

For better understand of “How to Create Table in Microsoft SQL Server”, here we creating Employee table. Here Employee is a Table name.

Query for create table in SQL Server:

Create Table employee (eno int, ename varchar(20), sal money)

Explanation of Query:

In the above query we created table with a name of employee. In the employee table columns are eno, ename and sal. For eno we are given int as data type, because eno values are integers (like 1, 2, 3, 4, 5 …..). For ename we are given varchar (20) as data type, because ename values are employee names (like Geetha reddy, Nanditha, Lathasree, naresh, shahid etc). Here one more thing you need to understand that is Varchar size. Here we are given varchar size as 20 that means the size of employee name should not be more than 20 characters. For sal we are given Money as data type, because employee salary is in terms of money. Here money is a default data type.

The Difference between Int and Money datatype.

If you are given int as data type for sal. (for example imagine salary of one employee is 10000). Then the output is as follows (like 10000)

If you are given money as data type for sal. (for example imagine salary of one employee is 10000). Then the output is as follows (like 10000.00)

If you want to see the difference between int data type and money data type, first you need to insert values in the table. Click here to insert Values in to the table

Like this you Can create any Table in MS SQl server with any type of column names and any type of data types.

You May also Search in Google as:
Query for creating Table in SQL server, creation of table in MS SQL server, in Microsoft SQL Sever how to create table, table create in SQL server. MS SQL server Table creation.




0 comments:

 
close

Join Telegram Channel

Join FreshersJobsUpdates - Your Job Search End Here

Join Telegram Channel