When is the UPDATE_STATISTICS command used? When the processing of large data is done, this command is used. Whenever large number of deletions, modification or copy takes place into sql server objective questions and answers pdf tables, the indexes need to be updated to take care of these changes. Differentiate between a HAVING CLAUSE and a WHERE CLAUSE.
HAVING CLAUSE is used only with the SELECT statement. It is generally used in a GROUP BY clause in a query. If GROUP BY is not used, HAVING works like a WHERE clause. It is applied to each row before they become a part of the GROUP BY function in a query. What do you understand by a view? What does the WITH CHECK OPTION clause for a view do?
A view is a virtual table that consists of fields from one or more real tables. It is usually used to join multiple tables and get the data. The WITH CHECK OPTION for a view prevents any modification to the data that does not confirm to the WHERE clause of the view definition. This allows the data belonging to the view to be updated through the view. A query execution plan shows how this optimizer would run the query. The jobs may run through a trigger, a predefined schedule or on demand. This service is very useful in determining why a particular job did not run as intended.
Using transactions we can group all SQL commands into a single unit. The transaction begins with some task and finishes only when all tasks within it are over. The transaction gets over successfully only when all commands in it are successfully over. Even if one command fails, the whole transaction fails.
The BEGIN TRANSACTION, ROLLBACK TRANSACTION, and COMMIT TRANSACTION statements are used to work with transactions. A group of tasks starts with the begin statement. In case of any problem, the rollback command is executed to abort the transaction. If all the tasks run successfully, all commands are executed through commit statement. Differentiate between a primary key and a unique key. By default, clustered index on the column are created by the primary key whereas nonclustered index are created by unique key. Primary key doesn’t allow NULLs, but unique key allows one NULL.
Is it possible for a stored procedure to call itself or recursive stored procedure? How many levels of SP nesting are possible? Recursion is method of problem solving where the solution is arrived at by repetitively applying the logic and solution to the subsets of the problem. So, yes it is possible for a stored procedure to call itself. Stored procedures and managed code references can be nested up to 32 levels.
What are the advantages of using Stored Procedures? They help in reducing the network traffic and latency which in turn boosts application performance. They help in promoting code reuse. They provide better security to data. It is possible to encapsulate the logic using stored procedures. This allows to change stored procedure code without affecting clients.
What do you mean by an execution plan? How would you view it? It is used because it is a very useful tool for a developer to understand the performance characteristics of a query or stored procedure. There exists an option called “Show Execution Plan” in Query Analyzer. If this option is turned on, it will display query execution plan in separate window when the query is run again. You want to implement the following relationships while designing tables.
How would you do it? It can be implemented as a single table and rarely as two tables with primary and foreign key relationships. By splitting the data into two tables with primary key and foreign key relationships. By using a junction table with the keys from both the tables forming the composite primary key of the junction table. Differentiate between DELETE and TRUNCATE. Truncate can not be rolled back while Delete can be.