Examples that are used to access data from sql server
6 Queries that are used to access data from sql server.
Table:1
/* Ist Table
Name: T_STUDENT */
CREATE TABLE T_STUDENT
(
STUDENT_ID int identity,
STUDENT_NAME varchar(200),
DOB varchar(50),
CITY_ID int
)
(
STUDENT_ID int identity,
STUDENT_NAME varchar(200),
DOB varchar(50),
CITY_ID int
)
STUDENT_ID STUDENT_NAME DOB CITY_ID
SELECT * FROM T_STUDENT
STUDENT_ID STUDENT_NAME DOB CITY_ID
1 jeenu utreja 15/09/1991
2 divya verma 08/02/1992
3 khushboo medhavi 06/08/1990
4 jyoti gauri 26/05/1986
5 neha 12/06/1986
Table:2
2.) Code for Creating Second Table
in SQL:
/* 2nd Table Name: T_STUDENT_PHONE */
CREATE TABLE T_STUDENT_PHONE
(
PHONE_ID INT IDENTITY,
STUDENT_ID INT,
PHONE_TYPE INT,
PHONE_TEXT VARCHAR(40),
)
PHONE_ID
|
STUDENT_ID
|
PHONE_TYPE
|
PHONE_TEXT
|
SELECT * FROM T_STUDENT_PHONE
PHONE_ID
|
STUDENT_ID
|
PHONE_TYPE
|
PHONE_TEXT
|
1 1 1 7676876772
2 1 2 9988676578
3 2 3 9877676776
4 2 4 9865455676
5 3 1 9776666777
6 3 2 9776677776
Table:3
3.) Code for Creating Third Table in
SQL:
/* 3rd Table
Name: T_STUDENT_PHONE_TYPE */
CREATE TABLE T_STUDENT_PHONE_TYPE
(
PHONE_TYPE INT IDENTITY,
PHONE_TYPE_TEXT VARCHAR(50)
(
PHONE_TYPE INT IDENTITY,
PHONE_TYPE_TEXT VARCHAR(50)
)
PHONE_TYPE
PHONE_TYPE_TEXT
SELECT * FROM T_STUDENT_PHONE_TYPE
PHONE_TYPE
PHONE_TYPE_TEXT
1 Home No.2 Mobile No.
3 Mother Mobile No.
Table:4
4.) Code for Creating Fourth Table
in SQL:
/* 4th Table
Name: T_STUDENT_CITY */
CREATE TABLE T_STUDENT_CITY
(
CITY_ID INT IDENTITY,
CITY_NAME VARCHAR(200)
)
(
CITY_ID INT IDENTITY,
CITY_NAME VARCHAR(200)
)
CITY_ID
CITY_NAME
SELECT * FROM T_STUDENT_CITY
CITY_ID
|
CITY_NAME
|
|||
130 | Rajpura | |||
131 | Chandigarh | |||
132 | Ambala | |||
133 | Patiala |
No comments:
Post a Comment