Anda di halaman 1dari 3

36. Left outer joins and Right Outer joins A.

Joins are used to join 2 or more tables using some conditions. There are 3 ty pes of Joins in SQL Server databasea. Left Outer Join b. Right Outer Join c. Full Join In order to extract the matched row from both the tables and unmatched row from the first table, left Outer join is used. The syntax for left outer join conditi on is: T.Col1* = T2.Col1 In order to extract the matched row from both the tables and unmatched row from the second table, right Outer join is used. The syntax for right outer join cond ition is: T.Col1 = *T2.Col1 In order to extract the matched row from both the tables and unmatched row from the first table and then unmatched row from the second table, full join is used. The syntax for full join condition is: T.Col1* = *T2.Col1 37. Exception handling. A. Exception Handling is the way to handle the unexpected error. From the SQL Se rver 2005 version, try catch block is also supported to catch the exceptions in SQ L Server database. There is various other ways to catch the error like @@Error w hich is the global variable and used to get the error. RaiseError is another inb uilt method which is used to display the error. 38. What is Performance Tuning? How do you implement it. A. Performance Tuning is the process through which we can optimize the SQL Serve r objects like functions, triggers, stored procedure so that we can achieve high response time to the front end. In the performance tuning process we generally check for the below point and optimize the objects processing: a. Through Query Execution plan, check for the processing time of the query exe cution. b. Check the join conditions and break all the condition for executions of the q ueries individually c. Check for the error prone process, conditions in the queries. d. Check for the loops whether they are terminated if any error occurs e. Check for the processes which are taking more time in execution and how to re duce the response time. 39. Difference between Having and Where clauses. A. When the where clause is not able to evaluate the condition which consists o f group functions, Having clause is used. Having clause is always followed by th e Group By clause. Where clause is used to filter the records based on the conditions. If there is the requirement to get the group data in the select statement and where clause i s not able to get it, we can use the Having clause. e.g. Display DeptNo, No.of Employees in the department for all the departments w here more than 3 employees are working SELECT DEPTNO, COUNT(*) AS TOTAL_EMPLOYEE FROM EMP GROUP BY DEPTNO HAVING COUNT(*) >3 40. Difference between Temp tables and Tables variables? A. Temp Table in SQL Server: a. Temp table is the special type of tables which are used to store the intermed iate data of the actual table. b. Temp tables are only visible to the current sessions of the sql server instan ce. When the session end, these table data automatically drops. c. We can t join the temp tables as they don t allow the foreign key constraints.

d. Temp tables are created in TempDB database. e. We can use the same temp table name for the different user sessions. f. Mostly used in stored procedure to handle the intermediate data. 41. What does @ and @@ suffixed by property names specify? A. @- This is used for the variable declaration e.g. @name varchar2(50) @@- This is used for the Global variable declaration e.g. @@Error=0 42. Self-join queries. A. Self-Join is a type of join which is used to join the same table by creating the second instance of the same table. So we join 2 instances of the same table in case of self-join. This type of join is used when there is the requirement to get the referenced data which is available in the same table. e.g. A table contains EmpId, Ename and ManagerId As the manager id is also an employee id. Now if we want that who is the manager of which employee. In this situation, we need to create the instance of the sam e table and get the required data as: SELECT EMPID, ENAME, ENAME AS [MANAGER NAME] FROM EMP E1, EMP E2 WHERE E1.EMPID= E2.MANAGERID 43. Types of Index. A. Indexes are one the database objects which is used to improve the performanc e of the database queries. it reduces the table scan while retrieving the data f rom the database and the search gets fastThere are 2 types of indexes used in the SQL server: a. Clustered index b. Non clustered index There are 3 more types of index but those comes under the above twoa. unique index b. Composite Index c. XML Index-added in SQL Server 2005 The index basically works on searching like binary tree where the root value is the finding value and it will be compared with the partitioned value of the tree . 44. Difference between Primary key, Unique key and Candidate key? A. Primary Key- It is a key to make the unique identification of the row in a ta ble. It doesn t allow null values in the primary key column. We can create the loo kup columns based on the primary key. One table allows maximum of 1 primary key and in 1 table, we can create the primary key column by using 16 columns. Due to one of the normalization rule, we have to create primary key for the table to m ake the rows unique. Unique Key:- Primary Key+ Not null is called as unique key. Unique key is also u sed to make the rows as unique in a table. The only difference between primary k ey and unique key is that primary key doesn t allow null value while the unique ke y allow. The limitation of the null in unique key is that it allows only one Nul l so in only one row; we can make the key as null for the unique key. Candidate key- the key other than primary key to make the rows as unique is call ed as candidate key. In candidate key, we take the columns which are not in the primary key and make the key for uniqueness of the row. 45. What is the default value for Date type. What are Min and Max values f or Date in 2008. A. The default value of Date is CURRENT_TIMESTAMP Below are the new date and time values in Sql Server 2008: In SQL Server 2008: 1. DateTime2

Min Value: Max Value: 2. Date Min Value: Max Value:

0001-01-01 00:00:00.0000000 9999-12-31 23:59:59.9999999 0001-01-01 9999-12-31

Anda mungkin juga menyukai