Вы находитесь на странице: 1из 7

List of Questions

1.

What are Aggregate functions? Explain Aggregate functions in SQL SERVER 2008 with

 

2

2.

Name the Basic or Default Databases of SQL SERVER and What are their functions and

use.?

2

3.

SQL Server 2008 advantages for Developers

3

4.

New features in SQL SERVER 2008

4

5.

Explain ACID properties of the database?

5

6.

Why Primary Keys and Foreign Key Relationships important in Database? Why we create

Primary Keys and Foreign Key Relationships. Do they affect any performance in SQL SERVER .5

7. What is the difference between subqueries and join in sql server

5

8. What is @@ERROR Variable in SQL SERVER? Why it is used in SQL Server stored

Procedures?

5

9.

What is the maximum number of tables we use for joins in a single query? Actually in a

single query how many tables we can join

5

10. What types of Joins are possible with Sql Server?

5

11. What is the difference between a HAVING CLAUSE and a WHERE CLAUSE in SQL

Statements?

6

12. What is Index? What types of indexes are supported in Microsoft SQL Server

6

13. What is sub-query? Explain properties of sub-query

6

14. What

are types of sub-queries?

7

1. What are Aggregate functions? Explain Aggregate functions in SQL SERVER 2008 with example.

Aggregate functions are applied to a group of data values from a column. Aggregate functions always return a single value.

SQL SERVER 2008 / Transact-SQL supports following aggregate functions:

AVG: Calculates the arithmetic mean (average) of the data values contained within a column. The column must contain numeric values.

MAX and MIN: Calculate the maximum and minimum data value of the column, respectively. The column can contain numeric, string, and date/time values.

SUM: Calculates the total of all data values in a column. The column must contain numeric values.

COUNT: Calculates the number of (non-null) data values in a column. The only aggregate function not being applied to columns is COUNT(*). This function returns the number of rows (whether or not particular columns have NULL values).

COUNT_BIG: New and Analogous to COUNT, the only difference being that COUNT_BIG returns a value of the BIGINT data type.

Aggregate function Example:

SELECT ProjectName, SUM(budget) TotalBudget FROM Project_Tbl GROUP BY ProjectName;

2. Name the Basic or Default Databases of SQL SERVER and What are their functions and use.?

Microsoft SQL SERVER Provides 4 default databases

The Master database holds information for all databases located on the SQL Server instance and is the glue that holds the engine together. Because SQL Server cannot start without a functioning master database, you must administer this database with care.

The tempdb holds temporary objects such as global and local temporary tables and stored procedures. The model is essentially a template database used in the creation of any new user database created in the instance.

The msdb database stores information regarding database backups, SQL Agent information, DTS packages, SQL Server jobs, and some replication information such as for log shipping.

3.

SQL Server 2008 advantages for Developers

Microsoft has released a new version of its popular Database management system (SQL Server). It is Microsoft SQL Server 2008. So what are the benefits of SQL SERVER 2008 for Developers & Programmers.

SQL Management Studio improvements including IntelliSense.

New Data Types for just dates or times (no more storing time when you only need the date).

New Hierarchical data support .IsDescendent(), that can automatically pull a hierarchical view of data (no more custom recursive queries).

New Grouping Sets statement which enables you to automatically group dimensions in a query for easy aggregation and reporting.

New Merge statement which provides automatic insert/update semantics for keeping multiple data sources in sync.

New data types and support for Geodata and geometry.

New support for optimizing "empty" or row/column tables using the sparse keyword.

New FileStream attribute that enables you to include files that are stored in the server file system, but can be managed by SQL Server.

Increase the precision of storing and managing DATE and TIME information.

Store semi-structured and sparsely populated sets of data efficiently, using Sparse Columns.

New fully integrated Full-Text Indexes enable high-performance, scalable, and manageable Full- Text Indexing.

Create large User-Defined Types and User-Defined Aggregates greater than 8 KB.

Pass large amounts of data easily to functions or procedures using new Table-Value Parameters.

Perform multiple operations efficiently with the new MERGE command.

Model hierarchical data, such as org charts, or files and folders, using the new HierarchyID data type.

Build powerful location-aware applications, using SQL Server’s new standards-compliant spatial data types and spatial indexing capabilities.

Manage files and documents efficiently with full SQL Server security and transaction support, using the powerful new FILESTREAM data type.

Easily identify dependencies across objects and databases, using New Dependency Management.

Experience faster queries and reporting with Grouping Sets through powerful ANSI standards- compliant extensions to the GROUP BY clause.

Experience efficient, high-performance data access, using new Filtered Indexes for subsets of data.

4. New features in SQL SERVER 2008

Analysis Scale and Performance SQL Server 2008 drives broader analysis with enhanced analytical capabilities and with more complex computations and aggregations. New cube design tools help users streamline the development of the analysis infrastructure enabling them to build solutions for optimized performance.

Star Join Query Optimizations SQL Server 2008 provides improved query performance for common data warehouse scenarios. Star Join Query optimizations reduce query response time by recognizing data warehouse join patterns.

Partitioned Table Parallelism Partitions enable organizations to manage large growing tables more effectively by transparently breaking them into manageable blocks of data. SQL Server 2008 builds on the advances of partitioning in SQL Server 2005 by improving the performance on large partitioned tables.

Integrated Full Text Search Integrated Full Text Search makes the transition between Text Search and relational data seamless, while enabling users to use the Text Indexes to perform high-speed text searches on large text columns.

DATE/TIME SQL Server 2008 introduces new date and time data types:

DATE—A date-only type

TIME—A time-only type

DATETIMEOFFSET—A time-zone-aware datetime type

DATETIME2—A datetime type with larger fractional seconds and year range than the existing DATETIME type

MERGE SQL Statement With the introduction of the MERGE SQL Statement, developers can more effectively handle common data warehousing scenarios, like checking whether a row exists, and then executing an insert or update.

Enhanced Database Mirroring SQL Server 2008 builds on SQL Server 2005 by providing a more reliable platform that has enhanced database mirroring, including automatic page repair, improved performance, and enhanced supportability.

Transparent Data Encryption Enable encryption of an entire database, data files, or log files, without the need for application changes. Benefits of this include: Search encrypted data using both range and fuzzy searches, search secure data from unauthorized users, and data encryption without any required changes in existing applications.

5.

Explain ACID properties of the database?

All Database systems which include transaction support implement ACID properties to ensure the integrity of the database. ACID stands for Atomicity, Consistency, Isolation and Durability

Atomicity: Each transaction is said to be “atomic.” If one part of the transaction fails, the entire transaction fails. Modifications on the data in the database either fail or succeed.

Consistency: This property ensures that only valid data will be written to the database. If, for some reason, a transaction is executed that violates the database’s consistency rules, the entire transaction will be rolled back and the database will be restored to a state consistent with those rules.

Isolation: It requires that multiple transactions occurring at the same time not impact each other’s execution.

Durability: It ensures that any transaction committed to the database will not be lost.

6. Why Primary Keys and Foreign Key Relationships important in Database? Why we create Primary Keys and Foreign Key Relationships. Do they affect any performance in SQL SERVER

Primary keys and foreign key relationships that are correctly defined help ensure that you can write optimal queries. One common result of incorrect relationships is having to add DISTINCT clauses to eliminate redundant data from result sets.

When primary and foreign keys are defined as constraints in the database schema, the server can use that information to create optimal execution plans.

7. What is the difference between subqueries and join in sql server

If we want to retrive data from more than one table byusing join conditions then we go to join based on the type type of join condition. Sub query is nested quires there is no need of any join condition

8. What is @@ERROR Variable in SQL SERVER? Why it is used in SQL Server stored

Procedures? The @@ERROR automatic variable in SQL SERVER returns the error code of the last Transact- SQL statement. If there was no error, @@ERROR returns zero. Because @@ERROR is reset after each Transact-SQL statement, it must be saved to a variable if it is needed to process it further after checking it.

9. What is the maximum number of tables we use for joins in a single query? Actually in a single query how many tables we can join

We can join 256 tables in a join.

10. What types of Joins are possible with Sql Server?

Joins are used in SQL queries to explain how different tables are related. Joins also let you select data from a table depending upon data from another table.

Joins are used to retrieve data from more than one table based a common field. Based on ur query, the output is taken from 2 or more tables

Types of joins: INNER JOIN, OUTER JOIN, CROSS JOIN. OUTER JOIN are further classified as LEFT OUTER JOINS, RIGHT OUTER JOINS and FULL OUTER JOINS

11. What is the difference between a HAVING CLAUSE and a WHERE CLAUSE in SQL Statements?

Both HAVING and WHERE clause used for specifying the search condition in SQL queries.

HAVING can be used only with the SELECT statement. HAVING is typically used in a GROUP BY clause. When GROUP BY is not used, HAVING behaves like a WHERE clause. Having Clause is basically used only with the GROUP BY function in a query.

WHERE Clause can be used for specifying the search criteria in SELECT, DELETE, UPDATE statements.

12. What is Index? What types of indexes are supported in Microsoft SQL Server.

An index is a physical structure containing pointers to the data. Indexes are created in an either existing table to locate rows more quickly and efficiently or It is possible to create an index on one or more columns of a table, and each index is given a name. The users cannot see the indexes; they are just used to speed up queries. Effective indexes are one of the best ways to improve performance in a database application.

A table scan happens when there is no index available to help a query. In a table scan SQL

Server examines every row in the table to satisfy the query results. Table scans are sometimes unavoidable, but on large tables, scans have a terrific impact on performance. There are two types of indexes are available in SQL SERVER

Clustered indexes define the physical sorting of a database table’s rows in the storage media. For this reason, each database table may have only one clustered index.

A clustered index is a special type of index that reorders the way records in the table are

physically stored. Therefore table can have only one clustered index. The leaf nodes of a clustered index contain the data pages

Non-clustered indexes are created outside of the database table and contain a sorted list of references to the table itself. Non-clustered indexes can be multiple.

A non-clustered index is a special type of index in which the logical order of the index does not

match the physical stored order of the rows on disk. The leaf node of a non-clustered index does

not consist of the data pages. Instead, the leaf nodes contain index rows of references to the

table

More references: http://www.techbaba.com/q/284-indexes+sql+sever+index+types.aspx

13. What is sub-query? Explain properties of sub-query.

Sub-queries are often referred to as sub-selects, as they allow a SELECT statement to be executed arbitrarily within the body of another SQL statement. A sub-query is executed by enclosing it in a set of parentheses. Sub-queries are generally used to return a single row as an atomic value, though they may be used to compare values against multiple rows with the IN keyword.

A subquery is a SELECT statement that is nested within another T-SQL statement. A sub query

SELECT statement if executed independently of the T-SQL statement, in which it is nested, will return a result set. Meaning a sub query SELECT statement can standalone and is not depended on the statement in which it is nested. A sub query SELECT statement can return any number of

values, and can be found in, the column list of a SELECT statement, a FROM, GROUP BY, HAVING, and/or ORDER BY clauses of a T-SQL statement. A Sub query can also be used as a parameter to a function call. Basically a sub query can be used anywhere an expression can be used.

Properties of Sub-Query

A sub query must be enclosed in the parenthesis.

A sub query must be put in the right hand of the comparison operator, and

A sub query cannot contain a ORDER-BY clause.

A query can contain more than one sub-queries.

14. What are types of sub-queries? Single-row sub query, where the sub query returns only one row. Multiple-row sub query, where the subquery returns multiple rows,.and Multiple column sub query, where the sub query returns multiple columns.