Microsoft Sql Server

By
Sql Server is a relational database management system (RDBMS) developed by Microsoft that's designed for the enterprise environment.It is a software product whose primary function is to store and retrieve data as requested by other software application.The original sql server code was developed by sybase in the late 1980.
The first version of sql server was sql server 4.2.The latest version of sql server is sql server 2012.
Create Database Through Sql command:-
SYNTAX:-

 create database database Name

EX:-   create database rsv


Create table in database:-

SYNTAX:-
create table table Name (column1 data type,column2 data type, column3 data type)

EX:-   create table student(sid int, sname varchar(30),sage int)


Insert Data in table :-
SYNTAX:-
insert into table Name values(value1,value2,value3)
OR
insert into  table Name ( column1 , column2 , column3 )values( value1,value2,value3 )
OR
insert  table Name values( value1,value2,value3 )

EX:-
insert into student values(101,'vinod',22)
OR
insert into student(sname,sid,sage)values('neha',102,22)
OR
insert student values(103,'manoj',21)

NOTE:-Here 'INTO' is optional.

Fetch the value from database table:-
SYNTAX:-
select*from table Name

EX:- select*from student


Update Existing Records in the Table:-

SYNTAX:-  update Table Name set column1=value,column2=value  where column3=value

EX:- update student set sname='ram',sage=25  where sid=103


Delete the record from the table:-
SYNTAX:-
delete from table Name where column =value

EX: delete from student where sid=103


Note:-  After the "WHERE" Clause we give the some condition,if any column have primary or unique key then we use that column after the " WHERE ".Here we have not specified any primary key or unique key , we will discuss it soon.

Add New Column In Existing Table:-
SYNTAX:-
alter table table Name add column data type

EX:-
alter table student add saddress varchar(40)


Change the Size of Existing Column in the Table:-

SYNTAX:-
alter table  table Name  alter column column Name data type

EX:-
alter table student alter column saddress varchar(80)

Drop The Existing Column from the Table:-
SYNTAX:-
alter table  table Name  drop column column Name
EX:-
alter table student drop column saddress


Change The Column Name In Existing Table:-
SYNTAX:-
sp_rename 'tableName.oldcolumnName','NewColumnName','column'

EX:-
sp_rename 'student.sage','s_age','column'


Change The Existing Table:-

SYNTAX:-
sp_rename ' oldtable Name ',' Newtable Name ','object'

EX:-
sp_rename 'student','studentdetails','object'


To Know the Structure of Database Table:-

SYNTAX:- 
sp_help table Name

EX:-

sp_help studentdetails

How to Delete a table:-
SYNTAX:-
Drop table Table Name
EX:-
Drop table studentdetails
For More:-
  1. Data Integrity 
  2. Create Table Without Command
  3. Check constraints
  4. Default Constraints
  5. Add Identity Column
  6. Copy Data from one table to another table
  7. Stored Procedure
  8. oops concepts
To Get the Latest  Free Updates Subscribe
Click Below for download whole Commands.

0 comments:

Post a Comment

Powered by Blogger.