Sql Server Interview Questions and Answers Part 3

By
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(sid int constraint pk_sid primary key,sname varchar(40),sage 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 sid int not null

Now create constraints on existing table's column:-

alter table student add primary key (sid).

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 scource add constraint fk_sid foreign key(sid) references student(sid)

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

8.) How can delete the a constraint from table in  Sql server  ?                                    
alter table scource 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 studentdetails(sid int primary key,sname varchar(40),sage int)

11.) How to create constraints at table level  in sql server?                                           
Create table student (sid int, sname varchar(40),sage int,constraint pksid primary key( sid,sname,sage))

0 comments:

Post a Comment

Powered by Blogger.