Share Blog

Thursday, May 29, 2014

Sql Server Interview Questions and Answers

1.) What is Data Integrity in sql server?                                                                              


The Consistency of data is known as data Integrity.If Data integrity concepts is applied on table then data will become in consistence form.Means we can easily access a specific value from table easily.

2.) What types of data integrity concepts are used in sql sever?                               

  • Entity Integrity
  • Referential Integrity
  • Domain Integrity
3.) How can create primary key constraints on a table's column in
 sql server ?  

create table student(id int constraint pk_id primary key,name varchar(50),age int)


4.) How can add primary key constraints on a Existing table in
 sql server ?         
Before Creating Primary key on a table.First make table not null able as given below:

alter table student alter column id int not null


Now create constraints on existing table's column:- 

alter table student add primary key (id).


5.) How to check whether constraints are present in table or not  ?                         
sp_help constraint student

6.) What is Referential Integrity in Sql server  ?                                                                
If a table column refer to another table column, then both column(parent, child) have same value as specify within parent column.we can't delete parent table if child table is exist in database.
here my two tables are:-

  • Student
  • Scourse

Example:-
alter table cource add constraint fk_id foreign key(id) references student(id)

7.) How can fetch the multiple table values in  Sql server  ?                                         
select *from student,course

8.) How can delete the a constraint from table in  Sql server  ?                                    
alter table cource drop constraint fk_sid

9.) What is Domain Integrity in  Sql server  ?                                                                       
Domain Intigrity insures that values within the column should be according to the "Business logic" (within specify range).To implement this integrity we can specify the 'Check constraint' and 'Default constraint'.

10.) How to create constraints at column level  on a table ?                                         
create table student(id int primary key,name varchar(50),age int)

11.) How to create constraints at table level  in sql server?                                           
Create table student (id int, sname varchar(50),age int,constraint id primary key( id,name,age))

No comments:

Post a Comment