Sql Server Interview Questions and Answers Part 7

By
1.) What are the Joins Concepts in SQL Server ?                                                    

Joins are the concepts which are used to get the related data from more than one table in SQL Server.That is basically used to get the more than one related tables data by a single sql command.

2.) What are the types of Joins used in SQL Server ?                                              
  1. Inner Join
  2. Outer Join
  3. Self Join
  4. Cross Join
3.) What is Inner Join and why we use it in SQL Server ?                                      
In Inner Join , we get values from those table which have at least one column same.If no column value is same then we can't use inner join concepts on those tables.
If we want to get only those tables records whose values are same in all the joined tables. 
Ex.
select sid,sname,cname from  studentdetails  join scourse
on id=sid



4.) What is  Outer Join in SQL Server ?                                                                   
If we want to get matched as well as unmatched records from two or more joined tables then we can use outer join concepts. 

5.) What are the types of  Outer Join in SQL Server                                             

  1. Left Outer Join
  2. Right outer join
  3. Full outer join

6.) What is Left Outer Join in SQL Server                                                            
If we want to show matched and unmatched records from left side table and matched record only right side table,then we can use left outer join concepts.
Ex.
select sid,sname,course_name,sage from scourse c Left join studentdetails s on c.id=s.sid  

7.) What is right Outer Join in SQL Server                                                          
if we want to show matched ,unmatched records from right side table and matched records only left side table ,then we can use Right outer join concepts.
Ex.
select sid,sname,course_name from scourse c Right join studentdetails s 
on c.id=s.sid


8.) What is Full Outer Join in SQL Server                                                            
If we want to display all matched and unmatched records from left and right side table then ,we can use full outer join concepts.
Ex
select sid,sname,course_name from scourse c  full outer join studentdetails s on c.id=s.sid

9.) What is Self Join concepts in SQL Server                                                        
When the related data exist within the same table then we can implement self join concepts in SQL Server.
Ex.
Select s.sid,s.sname,T.sid ,T.sname from students s join students T on s.sid =T.sid

10.) What is Cross Join concepts in SQL Server                                                   
If one table is join with another table without any column basis,so the total number of output will be one table row second table row.
Ex.
select sid,sname,course_name from scourse c cross join students s

11.) What are the two sql commands that are used to get the same records form two or more tables

  1. Select*from students,scourse
  2. select sid,sname,course_name from scourse c cross join students s

0 comments:

Post a comment

Powered by Blogger.