IHostAzure.com | Cheap and Reliable SQL Server 2008 hosting. Hello friends. Today I am sharing my article about how to create databases, create tables, insert values into tables and update, delete and so on. I know this is basic information but I know this article will be helpful for all beginner students.
You need to first install .Net and then you need to install Microsoft SQL Server, any version. I have installed SQL Server 2008 .
After installation, connect to the database
Coding
create database School2; /*School2 database name*/
use school2; /*use query for select database*/
Create table Student /* create table_Name(Student)*/
(
Batch varchar(25)not null,
Reg_No Varchar (25) primary key not null,
Course varchar(20)not null,
Name_ varchar(15) not null,
Last_Name varchar(10) not null,
Fahter_Name varchar(18)not null,
Age int not null,
Sex varchar(8) not null,
Parent_Mo_No Bigint not null,
Student_Mo_no Bigint not null,
Nationality varchar(15) not null,
State varchar(15) not null,
City varchar(15) not null,
Local_Address varchar(30) not null,
Pin_Code bigint not null,
Parent_Occupation varchar(15) not null,
Total_Rs int not null,
Date_ datetime
);
select * from Student; /* select * form means show all data form table*/
insert into student values('LLB_08_2ndy','776678','LLB','alexia','anjali','mark marquest',23,'Male',9891688420,9968022717,'Indian','Bihar','Patna','Ny 26A',800001,'Gov job',90000,5/12/1986);
insert into student values('BA_1stYear','776683','Pol Science','Rajat','Singh','Suman Singh',23,'Male',9565434560,9716157368,'Indian','Delhi','New Delhi','Mahipalpur New Delhi',110037,'Businessman',70000,5/05/2015)
delete from Student where Student_Mo_no='9540434299'; /* Delete query use for delete insert recored form table */
update student set Date_ =04/04/2015 where Reg_No='776678'; /*update query use for update in existing data add new data*/
More select query using conditional expression
select * from Student where Total_Rs=7000; /*this quary based on search particular details using where clause...*/
select * from Student
where Course ='cs'
AND Reg_No ='776679'; /*AND Operator using this quary both condition true then value will print.*/
select * from Student
where Last_Name ='pamelov'
OR Reg_No='776679'; /*OR Operator using this quary if any condition will true value will print if both are true both value print.*/
select * from student
where State ='bihar'
AND(Reg_No ='776678' OR Reg_No='776679'); /*this quary using both AND & OR Operator print value only AND Operator*/
A constraint is a condition or check for an application on a field or set of fields.
- Delete is a DML command and drop is a DDL command
- Delete is used to delete rows from a table whereas drop is used to remove the entire table or database from the database.
- Update is a DML command and alter is a DDL command
- Update is used to update data in an existing table
So friends, this is a small article that will help you with “How to Create a Database in SQL Server 2008“.
Next time I will provide more interesting commands. Thank you. I Hope this is helpful for you. Enjoy, 🙂
Thanks in advance,