Basic
Basic
BASIC
Transact-SQL (T-SQL)
ANSI-SQL
2. Describe different components in SQL Server Architecture?
The different components are as follows:
Database Engine: It is the core service for storing, processing and securing data
Analysis Services: It is an online analy cal data engine used in decision support and
BI solu ons
Repor ng Services: It includes a complete set of tools to create, manage and deliver
reports
Integra on Services: It is a pla orm for building enterprise-level data integra on and
data transforma ons solu ons
3. Describe different edi ons of SQL Server?
Microso has got different edi ons of SQL Server targe ng different users.
Enterprise
High end, all inclusive product
Support for Always-on availability
Advanced audi ng
Standard
Support for basic BI and repor ng features
Does not support advanced features such as data warehousing
BI
Includes all standard and enterprise edi on features
No support for advanced tuning
Express
SQL Server supports mul ple instances of SQL Server concurrently running on same
computer.
Default: It is solely iden fied by computer name.By default, components try to connect to
this instance
Named: It is iden fied by instance name specified during installa on of the instance
10. What are the different database objects in SQL Server?
Some of the Database objects are as follows:
Scalar func ons
System tables
System stored procedures
User defined tables
NTILE
ROW_NUMBER
19. What are the different batch programming control flow statements?
Procedural features are included in T-SQL for easier processing of data.Control flow
statements supported are as follows:
IF ELSE
While
CASE
Goto
20. What is user defined func on in SQL Server and enlist it’ types?
User defined func on is a T-SQL rou ne that returns a value. It can be invoked by query. It
can be executed like stored procedure. Types of user defined func ons are as follows:
Scalar
Inline table valued func on
Mul -statement table valued func on
21. Explain usage of triggers in SQL Server?
A trigger is a special kind of stored procedure that automa cally executes when an event
occurs in the database server. DML triggers execute when a user tries to modify data
through a data manipula on language (DML) event. DDL triggers execute in response to a
variety of data defini on language (DDL) events. SQL Server allows for crea ng mul ple
triggers for any specific statement.
22. Explain different types of trigger in SQL Server?
There are three type of Triggers
DML Triggers
Instead of Trigger: Instead of trigger are fired in place of the triggering ac on
such as an insert, update, or delete
A er Trigger: A er trigger execute following the triggering ac on, such as an
insert, update, or delete.
DDL Triggers: This type of trigger is fired against DDL statements like Drop Table,
Create Table or Alter Table. DDL Triggers are always a er Triggers
Logon trigger: This type of trigger is fired against a LOGON event before a user
session is established to the SQL Server
23. Explain excep on handling in SQL Server?
TRY…CATCH implements error handling for Transact-SQL .A group of Transact-SQL
statements can be enclosed in a TRY block. If an error occurs in the TRY block, control is
passed to another group of statements that is enclosed in a CATCH block.
24. What are different transac on control statements?
The three different transac on control statements are:
BEGIN: Alerts SQL Server that transac on is beginning
Rollback: Undoes the changes to the named savepoint or the beginning of
transac on
Commit: End the transac on and saves changes to the database
25. Which resources can be locked by database engine?
The following are the resources that the database engine can lock:
RID
Key
Page
Event
Table
File
Metadata
Applica on
Database
ADVANCED
Output clause returns informa on from each row affected by following statements:
UPDATE
DELETE
INSERT
MERGE
These results can be returned to the processing applica on to be used as confirma on
message.
28. Explain spa al types in SQL Server?
The geography spa al data type, geography, is implemented as a .NET common language
run me (CLR) data type in SQL Server. This type represents data in a round-earth coordinate
system. The SQL Server geography data type stores ellipsoidal (round-earth) data, such as
GPS la tude and longitude coordinates.
The planar spa al data type, geometry, is implemented as a common language run me
(CLR) data type in SQL Server. This type represents data in a Euclidean (flat) coordinate
system.
29. Explain advantages and drawbacks of FILESTREAM data type?
Advantages
Taken care by SQL Server
Reliable
Storage capacity is limited to disk volumes
Drawbacks
Assignment
Control of flow
Declare statement defining data variables
Select statement containing select list
TABLE variables
Calling Extended Procedures using Execute statement
32. What are the different types of stored procedures in SQL Server?
A stored procedure can take input parameters, return tabular or scalar results and messages
to the client. Types are as follows:
System
Temporary
Remote
Extended
User-defined
33. What are the special tables used with trigger?
DML trigger statements use two special tables: the deleted table and the inserted tables.
SQL Server automa cally creates and manages these tables. Func ons performed by them
are as follows:
Extend referen al integrity between tables.
Insert or update data in base tables underlying a view.
Test for errors and take ac on based on the error.
Find the difference between the state of a table before and a er a data modifica on
and take ac ons based on that difference
34. Why do we need snapshot isola on in SQL Server?
The term “snapshot” reflects the fact that all queries in the transac on see the same
version, or snapshot, of the database, based on the state of the database at the moment in
me when the transac on begins. Snapshot isola on uses an op mis c concurrency model.
If a snapshot transac on a empts to commit modifica ons to data that has changed since
the transac on began, the transac on will roll back and an error will be raised. When the
SNAPSHOT isola on level is enabled, each me a row is updated, the SQL Server Database
Engine stores a copy of the original row in tempdb, and adds a transac on sequence number
to the row.
35. Explain different types of lock mode in SQL Server?
Shared (S): Used for read opera ons that do not change or update data, such as a
SELECT statement.
Update (U): Used on resources that can be updated.
Exclusive (X): Used for data-modifica on opera ons, such as INSERT, UPDATE, or
DELETE.
Intent: Used to establish a lock hierarchy.
36. What are the key features of column store technology?
The key characteris cs of SQL Server column store technology are as follows:
Columnar data format
Faster query results
Key columns – There is no concept of key columns in a columnstore index
Par oning – Columnstore indexes works with table par oning
Record Size – The index key record size limita on of 900 bytes also does not apply to
columnstore indexes
37. How to detect and reduce fragmenta on in SQL Server?
Storing data non-con guously on disk is known as fragmenta on.
sys.dm_db_index_physical_stats is used to detect fragmenta on.
When an index is fragmented in a way that the fragmenta on is affec ng query
performance, there are three choices for reducing fragmenta on:
Drop and re-create the clustered index. Re-crea ng a clustered index redistributes
the data and results in full data pages.
Use ALTER INDEX REORGANIZE
Use ALTER INDEX REBUILD
38. Explain the different transac on modes supported by SQL Server?
Microso ’s SQL Server provides support for transac ons in three different modes of
opera on. They are as follows:
Implicit: If a transac on is implicitly started, then the transac on will con nue un l
it’s either fully commi ed or un l the transac on is rolled back
Explicit: Explicit mode is most commonly used in triggers, stored procedures and
applica on programs
Autocommit: In autocommit mode, each SQL statement is treated as a separate
transac on
39. Explain concept of principals in SQL Server?
Principals are en es that can request SQL Server resources. Types of principals are as
follows:
Windows Level-It includes window domain and window local login
SQL Server Level
Database Level-It includes database role, user and applica on role.
40. Explain few server level roles in SQL Server?
SQL Server provides server-level roles to help you manage the permissions on a server
sysadmin: Members of the sysadmin fixed server role can perform any ac vity in the
server
processadmin: Members of the processadmin fixed server role can end processes
that are running in an instance of SQL Server
diskadmin: The diskadmin fixed server role is used for managing disk files.
dbcreator: Members of the dbcreator fixed server role can create, alter, drop, and
restore any database.
41. What is the difference between contained and par ally contained database?
A contained database is a database that is isolated from other databases and from the
instance of SQL Server that hosts the database. A par ally contained database is a contained
database that can allow some features that cross the database boundary. SQL Server
includes the ability to determine when the containment boundary is crossed.
42. Explain some of the best prac ces to be adopted while using SQL Server?
Uncommi ed Read: This lets a transac on read any data currently on a data page,
whether or not that data has been commi ed
Commi ed Read: This ensures that an opera on will never read data another
applica on has changed but not yet commi ed
Repeatable Read: This isola on level adds to the proper es of Commi ed Read by
ensuring that if a transac on revisits data or if a query is reissued, the data will not
have changed
Serializable: This isola on level ensures that if a query is reissued, no data will have
changed and no new rows will appear in the interim