SQL Server Interview Questions and Answers PDF
SQL Server Interview Questions and Answers PDF
aspx
WHERE Clause
- It is applied to each row before they become a part of the GROUP BY function in
a query.
6. Comment on Transactions.
- 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.
b.) It is used because it is a very useful tool for a developer to understand the
performance characteristics of a query or stored procedure.
c.) 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.
b.) One-to-Many relationships - by splitting the data into two tables with primary key
and foreign key relationships.
c.) Many-to-Many - by using a junction table with the keys from both the tables
forming the composite primary key of the junction table.
Collation is a type of sort order. There are mainly three types of sort orders,
namely:
i.) Dictionary case sensitive
ii.)Dictionary - case insensitive
iii.)Binary.
- Global temporary tables (created with a double “##”) are visible to all sessions.
- Global temporary tables are dropped when the session that created it ends, and
all other sessions have stopped referencing it.
i.) Shared locks - they are used for operations which do not allow any change or
update of data. For e.g. SELECT.
ii.) Update locks - they are used when SQL Server wants to modify a page. The
update page lock is then promoted to an exclusive page lock before actually
making the changes.
iii.) Exclusive locks - they are used for the data modification operations. For e.g.
UPDATE, INSERT, or DELETE.
Can you explain about buffer cash and log Cache in sql server?
Latest answer: Buffer Cache: Buffer cache is a memory pool in which data pages
are read. It performance of the buffer cache is indicated as follows:.............
Read answer
Difference between control flow and data flow?, If you want to send some data from
Access database to SQL server database. What are different component of SSIS
will you use?, Explain why variables called the most powerful component of
SSIS?..................
Read answer
Latest answer: SQL Server has a feature for sending mail. Stored procedures can
also be used for sending mail on demand. With SQL Server 2005, MAPI client is
not needed for sending mails................
Read answer
Latest answer: Cross Join : No join conditions are specified. Results in pairs of
rows. Results in Cartesian product of two tables...............
Read answer
Latest answer: OPENXML parses the XML data in SQL Server in an efficient
manner. It’s primary ability is to insert XML data to the RDB. It is also possible to
query the data by using OpenXML................
Read answer
Latest answer: The following is the order of executing SQL query: The query goes
to the shared pool that has information like parse tree and execution plan for the
corresponding statement...............
Read answer
4 of 22 5/15/2015 10:21 PM
500 Sql server interview questions and answers - SQL FAQ PDF http://www.careerride.com/SQLServer-Interview-Questions.aspx
Latest answer: Create a column as type ‘blob’ in a table. Read the content of the
file and save in ‘blob’ type column in a table...............
Read answer
Explain the use of keyword WITH ENCRYPTION. Create a Store Procedure with
Encryption.
Latest answer: WITH ENCRYPTION Indicates that SQL Server will convert the
original text of the CREATE PROCEDURE statement to an encrypted format. Users
that have no access to system................
Read answer
Latest answer: A linked server allows remote access. Using this, we can issue
distributed queries, update, commands, and transactions across different data
sources................
Read answer
Latest answer: Analysis service provides a combined view of the data used in
OLAP or Data mining. Services here refer to OLAP, Data mining. Analysis services
assists in creating, designing...........
Read answer
Latest answer: Each server running analysis service has a repository to store
objects of the computer running Analysis Services an Analysis service repository
stores the information about the.............
Read answer
What is user defined datatypes and when you should go for them?
Latest answer: User defined datatypes is created by using base SQL Server data
type by providing a descriptive name.................
Read answer
Latest answer: Lock escalation from SQL Server 7.0 onwards, is dynamically
managed by SQL Server. It is..........
Read answer
5 of 22 5/15/2015 10:21 PM
500 Sql server interview questions and answers - SQL FAQ PDF http://www.careerride.com/SQLServer-Interview-Questions.aspx
Latest answer: Lock escalation from SQL Server 7.0 onwards, is dynamically
managed by SQL Server. It is..........
Read answer
What is blocking?
Latest answer: Blocking happens when one connection from an application holds
a lock and a second............
Read answer
Latest answer: Every database has a public role which holds all the default
permissions for the users in a database.................
Read answer
Latest answer: SQL server login is used to connect to SQL server. This used
when login in through the windows login credentials is not existent.............
Read answer
Latest answer: The built in Administrator Account is basically used during some
setup to join some machine in the domain............
Read answer
Latest answer: Failover clustering is mainly used for data availability. Typically in a
failover cluster, there are two machines. One machine provides the basic services
and the second is available to run..................
Read answer
Latest answer: SQL server can return XML document using FOR XML
clause.................
Read answer
Explain in brief how SQL server enhances scalability of the database system.
Latest answer: SQL Server has efficient ways to enhance scalability of the
database system...............
Read answer
Latest answer: SQL Server English Query helps to build applications that can
accept query.............
Read answer
Latest answer: SQL Profiler captures SQL Server events from a server. The
events are saved.................
Read answer
What are the ways available in SQL Server to execute SQL statements?
Latest answer: SQL Server uses different ways to execute SQL statements which
are listed below................
Read answer
Latest answer: SQL Server supports searches on character string columns using
Full-Text Query...............
Read answer
Latest answer: The several phases a transaction has to go through are listed here.
Database..............
6 of 22 5/15/2015 10:21 PM
500 Sql server interview questions and answers - SQL FAQ PDF http://www.careerride.com/SQLServer-Interview-Questions.aspx
Latest answer: The several phases a transaction has to go through are listed here.
Database..............
Read answer
What is XPath?
Latest answer: XPath is a language defined by the W3C, used to select nodes
from XML documents..............
Read answer
Define the rules for designing Files and File groups in SQL Server.
Latest answer: A file or file group can only be used by one database. For example,
the files abc.mdf and abc.ndf contains.................
Read answer
Explain Data Definition Language, Data Control Language and Data Manipulation
Language.
Latest answer: Data definition language is used to define and manage all
attributes and properties of a database..............
Read answer
Latest answer: SQL Server uses the following steps to process a single SELECT
statement............
Read answer
Explain GO Command.
What is the significance of NULL value and why should we avoid permitting null
values?
Latest answer: Null means no entry has been made. It implies that the value is
either unknown or undefined............
Read answer
Latest answer: UNION command selects distinct and related information from two
tables. On the other hand..............
Read answer
Latest answer: UNION command selects distinct and related information from two
tables. On the other hand.............
Read answer
7 of 22 Latest answer: A local temporary table lives until the connection is valid or until the 5/15/2015 10:21 PM
500 Sql server interview questions and answers - SQL FAQ PDF http://www.careerride.com/SQLServer-Interview-Questions.aspx
Latest answer: A local temporary table lives until the connection is valid or until the
duration of a compound statement.........
Read answer
What is the STUFF and how does it differ from the REPLACE function?
Latest answer: STUFF function is used to insert a string into another string by
deleting some characters specified.............
Read answer
Data regions are report items used to display data from a single dataset. You can
perform grouping, sorting and various aggregate functions on data in data region.
In SSRS 2005, there were 4 data regions:-
1. Table
2. Matrix
3. List
4. Chart
While in SSRS 2008, there are one additional data region namely Gauge.
Let’s explain each one of them:
1. Table - Table Data region has fixed tabular structure i.e. fixed number of
columns. It is useful for displaying data grouped by row. You can have maximum of
1 report item per cell. The size of table depends on number of rows dataset fetches
i.e., if number of rows returned by dataset is more; it can expand to multiple pages.
2. Matrix – A matrix data region display data in pivot table format, hence also
popularly known as pivot table or crosstab report. It has minimum of one row group
and one column group. The size of matrix data region depends on columns and
rows fetched.
3. List - A list data region is free layout. It is useful for complex reporting resign. The
list can be used to display multiple table and matrix. Each getting data from
different dataset.
4. Chart – This data region is for displays the data graphically i.e., in form of chart.
A various chart types are available in SSRS 2008 namely line, pie chart, columns
etc.
5. Gauge - This can be used in a table or matrix to show the relative value of a field
in a range of values in the data region. You can also add a gauge to the design
surface to show a single relative value.
There are various ways in which you can enhance your report:
6. MIN
7. STDEV
8. STDEVP
9. VAR
10. VARP
By default, SUM is the aggregate function used for numeric data type.
There are 3 ways in which you can integrate reports into your application:-
1. Navigating to URL i.e. https:\\servername\reportservername\reportname – This is
simplest and most popular way. A separate login might be required since we are
directly calling the report from report server. Address of report server gets expose
to user.
2. Using IFrame, Browser control or Report Viewer Control – In this approach, we
embed the URL of report server in our application, hence address of reportserver is
not exposed. No separate window opens. A user does not come to know that he
has moved to different server.
3. Programmatically sending a web request using SOAP to report server.
Property,
Context
S.No. Functionality Expression
and Dialog
Box
Colour for
a
Format data placeholder
in a text box inside of a =IIF(Fields!TotalDue.Value <
1
depending on text box in 10000,"Red","Black")
value the details
row for a
Tablix
Value for a
placeholder
inside of a
Dynamic
text box
page header ="Page " & Globals!PageNumber & " of " &
2 that is
or footer Globals!TotalPages
placed in
content.
the page
header or
footer.
Specify page
breaks for Group
every 20 expression
3 =Ceiling(RowNumber(Nothing)/20)
rows in a for a group
Tablix with no in a Tablix.
other groups.
Shows the
user ID of the
4 person Value =User!UserID
running the
report
To get first
5 day of the Value =DateSerial(Year(Today()),Month(Today()),1)
month
To get the
6 Value =Today()
current date
To get last
=DateAdd("d",-
7 day of the Value
1,DateSerial(Year(Today()),Month(Today())+1,1))
month
Both the drill down and drill through report provide interactive functionality to the
SSRS report. The differences are as follows:-
Drill
Trait Drill Down
Through
Data
9 of 22 retrieved one 5/15/2015 10:21 PM
500 Sql server interview questions and answers - SQL FAQ PDF http://www.careerride.com/SQLServer-Interview-Questions.aspx
Drill
Trait Drill Down
Through
Data
retrieved one
Data retrieved at the same time as click on link
Retrieves Data
main report of drill
through
report
Is processed and rendered When link is
With the main report
when clicked
Faster (but
does not
Slower since retrieves all data with
Performance retrieve all
main report
data with
main report)
Separately
either in
Is displayed Within main report separate
window or
tab
Custom fields can be defined as alias column of the report since the operation is
performed on report server rather than on database server. The custom field is very
useful for the data manipulation like adding some fields whose value can be
calculated based on expression, text e.g. instead of CName fetched from database,
I want the dataset to display Customer Name etc.
We can add custom fields as right click on dataset, select add in Dataset window.
The New field dialog box will open, we can add name of custom field and also
mention whether it is database field or calculated one. If it is calculated, then we
can mention the computation in this window.
Can we use custom code in SSRS? If so, explain how we can do.
Yes, we can. SSRS allows developer to add custom code in your report. You can
write the code directly into embedded VB.Net and call it using property expression
or you can write a custom class library and refer it in report server. The advantage
of first method is that it is simple and easy to use but disadvantage is that it is
available for that report only. While the second method has advantage of being
available for multiple reports but it has much of configuration overhead.
To write custom code, right click on Report Designer outside report body and select
Properties and go to Code tab and you can write custom code here.
To add custom class library, right click on Report Designer outside report body and
select Properties and go to Reference tab and add the reference by browsing to the
assembly of your class library. Note that you need to create class library and then
compile it before referencing it in your SSRS report.
Report
Query Parameter
Parameter
Defined At Database Level Report Level
Automatically if
report has some
Automatically if database query or
Created query parameter
stored procedure has a parameter
and is mapped to
query parameter
processed On Database Server On Report Server
Manipulate data,
interconnect
Use Filtering of Data, Security of Data
reports, filtering
data
Number of
records presented
is based on query.
Note- Records
Number of records returned is based processed on
Processing Output
on query parameter report parameter
would be same as
records returned
based on query
10 of 22 5/15/2015 10:21 PM
500 Sql server interview questions and answers - SQL FAQ PDF http://www.careerride.com/SQLServer-Interview-Questions.aspx
Reporting services maintain role based security. When a user logs into reporting
services, a Report Manager (whose duty is to maintain security of Reporting
Services) first checks the identity of user and then determine what rights he have to
perform on report.
Item-level roles – User can use any of predefined item-level roles or create their
own roles by using combination of predefined item-level roles.
Pre-defined Item-level roles are:-
1. Browser – can navigate to report and run them.
2. My Reports – these users’ rights is restricted to reports present in their
MyReports folder. However, they can create, view and manage reports in their
folder.
3. Publisher – As name suggest, publisher user has rights to publish reports to
Reporting Server database.
4. Content Manager – has all permission at item-level.
String sql = “Select EmpName, City from EmployeeMaster where EmpName like
‘%” + txtSearch.Text + “%’”;
This way attacker can get details of all the objects of the application database and
using that attacker can steal further information.
For example –
1. DBCC CHECKALLOC – It is used to check that all pages are correctly allocated
in database.
2. DBCC CHECKDB – It is used to check that
3. DBCC SQLPERF – It generates a report for the current usage of
4. DBCC SQLFILEGROUP – It used to check all the tables file group for any
design.
View result set doesn’t save anywhere on disk and executes the query
11 of 22 definition whenever they are called, while materialized view are disk based 5/15/2015 10:21 PM
500 Sql server interview questions and answers - SQL FAQ PDF http://www.careerride.com/SQLServer-Interview-Questions.aspx
View result set doesn’t save anywhere on disk and executes the query
definition whenever they are called, while materialized view are disk based
and its result set table is updated periodically.
Materialized view is similar to regular views but the output of select query
has been saved to a table.
View shows the latest data all the time while the materialized view only
shows the fresh data after its result table is updated either by setting a
schedule or based on the change in the underlying tables.
The performance of the view depends on how good the selected statement
the view has. If the select statement has too many joins then it the view will
perform poorly.
While in the case of materialized view, we are querying a table, which may
also be indexed, that increase its performance.
When a complex SQL statement has number of joins then it can be made
easier by using Common Table Expression.
Consider the following SQL statement.
SELECT * FROM (
SELECT emp.EmpName,dept.Department,emp.Gender FROM Employee emp
left join Department dept on emp.DeptID = dept.DeptID) E
WHERE E.Gender = ‘Male’
ORDER BY T.EmpName
This way the query can be made more readable and easy to understand.
A table can have only one Clustered Index at a time which is generally
created on primary key and can have more than one non clustered indexes
(maximum up to 999)
The leaf level of clustered index is actual data pages of the table. Whereas
in case of non-clustered index the leaf level is a pointer to the data.
Non-clustered index is faster than clustered index because when we use
DML statement on clustered index, performance issues may occurred since
it has to update the index every time a DML statement is executed.
Syntax of creative clustered / non clustered index is as follow
CREATE [CLUSTERED | NON CLUSTERED] INDEX index_name
ON <object> (column [ASC | DESC] [,…n])
-When we combine two queries using EXCEPT clause, it will returns distinct rows
from the first SELECT statement that are not returned by the second one.
-EXCEPT clause works the same way as the UNION operator of SQL and MINUS
clause in Oracle.
-The syntax of EXCEPT clause is as follow
SELECT column1 [, column2 ]
FROM table1 [, table2 ]
[WHERE condition]
EXCEPT
-The difference between EXCEPT and NOT IN clause is EXCEPT operator returns
12 of 22 all distinct rows from the rows returned by first select statement which does not 5/15/2015 10:21 PM
500 Sql server interview questions and answers - SQL FAQ PDF http://www.careerride.com/SQLServer-Interview-Questions.aspx
[WHERE condition]
-The difference between EXCEPT and NOT IN clause is EXCEPT operator returns
all distinct rows from the rows returned by first select statement which does not
exist in the rows returned by second select statement. On the other hand “NOT IN”
will return all rows from returned by first select statement which does not exist in
the rows returned by second select statement.
Index Seek and Index Scan are operation for query tuning in execution
plans.
Table Scan scans every record of the table. So the cost of proportional is the
number of rows of that table.
The Index Scan is preferred only when the table is small.
Index Seek only touches the rows which qualify and the pages that contain
that qualifying rows, so the cost of proportional is the number of qualifying
rows and pages instead of the number of rows in the table.
Index seek is preferred for highly sensitive queries.
RANK is one of the Ranking functions which are used to give rank to each
row in the result set of a SELECT statement.
For using this function first specify the function name, followed by the empty
parentheses.
Then specify the OVER function. For this function, you have to pass an
ORDER BY clause as an argument. The clause specifies the column(s) that
you are going to rank.
For Example
SELECT ROW_NUMBER() OVER(ORDER BY Salary DESC) AS
[RowNumber], EmpName, Salary, [Month], [Year] FROM EmpSalary
In the result you will see that the highest salary got the first rand and the
lowest salary got the last rank. Here the rows with equal salaries will not get
same ranks.
What is Trigger?
-In SQL the Trigger is the procedural code that executed when you INSERT,
DELETE or UPDATE data in the table.
-Triggers are useful when you want to perform any automatic actions such as
cascading changes through related tables, enforcing column restrictions,
comparing the results of data modifications and maintaining the referential integrity
of data across a database.
-For example, to prevent the user to delete the any Employee from EmpDetails
table, following trigger can be created.
-When someone will delete a row from the EmpDetails table, the del_emp trigger
cancels the deletion, rolls back the transaction, and prints a message "You cannot
delete any Employee!"
-If we want to execute any procedural code automatically on specific time either
once or repeatedly then we can create a Scheduled job for that code.
-Following are the steps to create a Scheduled Job.
-Using scheduled job you can also create alert and notifications.
13 of 22 5/15/2015 10:21 PM
500 Sql server interview questions and answers - SQL FAQ PDF http://www.careerride.com/SQLServer-Interview-Questions.aspx
-Using scheduled job you can also create alert and notifications.
-OPENXML data can be manipulated the same way we deal with database tables
by treating xml tags in the form of columns and the value in the form of rows.
-By using OPENXML Data can be inserted or updated very quickly without multiple
trips to the database.
-Example:
Sparse column is a type of column which is used to optimize storage for null
values.
When a column there is big number of null then by defining that column as
spars column we can save a large amount of disk space.
The drawback of sparse column is that it requires more space for the non
null values. When we define a column as sparse it requires additional 4 Byte
for not null values.
For example, a DATETIME column in a non-sparse column required 8 bytes
of storage whereas if we define that column as a sparse column then it will
require 12 bytes.
It is not possible to set ROWGUIDCOL and IDENTITY properties in sparse
column.
-RANK is one of the Ranking functions which are used to give rank to each row in
the result set of a SELECT statement.
-For using this function first specify the function name, followed by the empty
parentheses.
-Then specify the OVER function. For this function, you have to pass an ORDER
BY clause as an argument. The clause specifies the column(s) that you are going
to rank.
For Example
-In the result you will see that the highest salary got the first rand and the lowest
salary got the last rank.
Here the rows with equal salaries will get same ranks.
-Remember that the rank depends on the row's position in the result set, not on the
sequential number of the row.
14 of 22 What are cursors and when they are useful? 5/15/2015 10:21 PM
500 Sql server interview questions and answers - SQL FAQ PDF http://www.careerride.com/SQLServer-Interview-Questions.aspx
-Remember that the rank depends on the row's position in the result set, not on the
sequential number of the row.
-When we execute any SQL operations, SQL Server opens a work area in memory
which is called Cursor.
-When it is required to perform the row by row operations which are not possible
with the set-based operations then Cursor is used.
1. Implicate Cursor
SQL Server automatically manages cursors for all data manipulation statements.
These cursors are called implicit cursors.
2. Explicit Cursor
When the programmer wants to perform the row by row operations for the result set
containing more than one row, then he explicitly declare a cursor with a name.
They are managed by OPEN, FETCH and CLOSE.
-SQL has introduced Log Shipping feature to synchronize the Distributed Database
Server. Synchronize the database by copying Transaction logs, Backing up,
Restoring data. SQL Server Job Agents is used to make these processes
automatic.
-In the case of failure the Log Shipping will not transfer the server. That means it
will not redirect your application to other server. This has to be done manually.
-Log shipping synchronizes the database only. The main functions of Log Shipping
are as follows:
-SQL Server provides a graphical tool which helps system administrators to monitor
T-SQL statements of Database Engine.
-SQL Profiler can capture and store data related to every event to a file or a table.
1. To create a trace
2. To store the trace results in a table.
3. To watch the trace results when the trace runs
4. To replay the trace results
5. To start, stop, pause, and modify the trace results
Similarity
-These both command will only delete data of the specified table, they cannot
remove the whole table data structure.
Difference
-TRUNCATE is faster than DELETE, because when you use DELETE to delete the
data, at that time it store the whole data in rollback space from where you can get
the data back after deletion. In case of TRUNCATE, it will not store data in rollback
space and will directly delete it. You can’t get the deleted data back when you use
TRUNCATE.
-We can use any condition in WHERE clause using DELETE but you can't do it with
TRUNCATE.
15 of 22 5/15/2015 10:21 PM
500 Sql server interview questions and answers - SQL FAQ PDF http://www.careerride.com/SQLServer-Interview-Questions.aspx
-We can use any condition in WHERE clause using DELETE but you can't do it with
TRUNCATE.
-If table is referenced by any foreign key constraints then TRUNCATE will not work.
-Normalization is set of rules that are to be applied while designing the database
tables which are to be connected with each other by relationships. This set of rules
is called Normalization.
The 'fill factor' option indicate how full SQL Server will create each index
page.
When the index page doesn’t have free space for inserting a new row, SQL
Server will create new index page and transfer some rows from the previous
index page to the new index page. This process is called page split.
If we want to reduce the number of page splits then we can use Fill factor
option. Using Fill factor SQL will reserve some space on each index page.
The fill factor is a value from 1 through 100 that indicates the percentage of
the index page to be left empty. The default value for fill factor is 0.
If the table contains the data which is not changed frequently then we can
set the fill factor option to 100. When the table's data is modified frequently,
we can set the fill factor option to 80% or as we want.
1. Snapshot Replication.
2. Transactional Replication
3. Merge Replication
Merge replication replicate data from multiple sources into a single central
database.
The initial load will be same as in snapshot replication but later it allows
change of data both on subscriber and publisher, later when they come
on-line it detects and combines them and updates accordingly.
STUFF: This function is used to replace the part of string with some another string.
Syntax:
Example:
SELECT STUFF(‘Arpit',2,2,'mi')
Output: Amit
REPLACE: This function is used to replace all the occurrences of particular string
by another string.
Syntax:
REPLACE(String1, String2, String3)
Syntax:
REPLACE(String1, String2, String3)
Example:
SELECT REPLACE(‘Arpit Jain’,’i’,’m’)
Output: Arpmt Jamn
If you want to replace the first occurrence of “I”, Replace wouldn't work, because it
always replaces ALL occurrences of the string.
-Suppose we have a EmpDetails table in our database and there are certain
number of stored procedures in database. We want to know in which stored
procedure(s) table EmpDetails is used.
SELECT
sys.objects.name, sys.objects.type, sys.objects.type_desc,
sys.objects.schema_id, sys.syscomments.text
FROM sys.objects
INNER JOIN sys.syscomments ON sys.objects.object_id = sys.syscomments.id
where sys.syscomments.text like '%EmpDetails%'
And type ='P'
-In SQL Server there are two system tables “Inserted” and “Deleted” called Magic
tables.
-These are not the physical tables but the virtual tables generally used with the
triggers to retrieve the inserted, deleted or updated rows.
-When a record is inserted in the table that record will be there on INSERTED
Magic table.
-When a record is updated in the table that existing record will be there on
DELETED Magic table and modified data will be there in INSERTED Magic table.
-When a record is deleted from that table that record will be there on DELETED
Magic table.
It is not possible to change the table data with the use of User defined
functions but you can do it by using stored procedure.
The execution of User defined function will be stopped if any error occurred
in it. But in the case of Stored procedure when an error occurs the execution
will ignore the error and jumps to the next statement.
We can use User defined function in XML FOR clause but we can use
stored procedure in XML FOR clause.
It is not possible to make permanent changes to server environment
whereas stored procedure can change some of the server environment.
User defined functions do not return output parameters while stored
procedure can return output parameters.
Isolation – This property says that one transaction can not retrive the data that has
been modified by any other transaction until its completed.
COMMIT statement is used to end the current transaction and once the COMMIT
statement is exceucted the transaction will be permanent and undone.
COMMIT statement is used to end the current transaction and once the COMMIT
statement is exceucted the transaction will be permanent and undone.
Syntax: COMMIT;
Example:
BEGIN
UPDATE EmpDetails SET EmpName = ‘Arpit’ where Dept = ‘Developer’
COMMIT;
END;
ROLLBACK statement is used to end the current transaction and undone the
changes which was made by that transaction.
Example
BEGIN
Statement1;
SAVEPOINT mysavepoint;
BEGIN
Statement2;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK TO mysavepoint;
Statement5;
END;
END;
When we want to query on remote database server along with the local
database server then we can add the remote SQL server to local SQL
server in a same group using the concept called Linked Server.
We can query on both servers using T-SQL.
We can use stored Procedure sp_addlinkedserver, sp_addlinkedsrvlogin to
add new Linked Server.
By using Linked Server we can SQL statement in clean and easy way to
retrieve, join and combine remote data with local data.
What is a WITH(NOLOCK)?
What are the basic functions for master, msdb, model, tempdb
databases?
The Master database contains catalog and data for all databases of the SQL
Server instance and it holds the engine together. Because SQL Server
cannot start if the master database is not working.
The msdb database contains data of database backups, SQL Agent, DTS
packages, SQL Server jobs, and log shipping.
The tempdb contains temporary objects like global and local temporary
tables and stored procedures.
The model is a template database which is used for creating a new user
database.
Test your sql server knowledge with our multiple choice questions!
Next>> Part 1 | Part 2 | Part 3 | Part 4 | part 5 | part 6 | part 7 | part 8 | part
9
18 of 22 5/15/2015 10:21 PM
500 Sql server interview questions and answers - SQL FAQ PDF http://www.careerride.com/SQLServer-Interview-Questions.aspx
Next>> Part 1 | Part 2 | Part 3 | Part 4 | part 5 | part 6 | part 7 | part 8 | part
9
What is bit data type and what's the information that can be stored inside a
bit column?
- Bit data type is the smallest type used in a language. It is used to store the
boolean information of the form 1 (true) or 0 (false). The former versions of SQL
server doesn’t support NULL type in this but recent version such as SQL server
7.0 onwards it supports NULL state as well.
What is bit data type and what's the information that can be stored inside a
bit column?
- Bit data type is the smallest type used in a language. It is used to store the
boolean information of the form 1 (true) or 0 (false). The former versions of SQL
server doesn’t support NULL type in this but recent version such as SQL server
7.0 onwards it supports NULL state as well.
No indexes
A clustered index
A clustered index and many nonclustered indexes
A nonclustered index
Many nonclustered indexes
What is BCP?
21 of 22 5/15/2015 10:21 PM
500 Sql server interview questions and answers - SQL FAQ PDF http://www.careerride.com/SQLServer-Interview-Questions.aspx
22 of 22 5/15/2015 10:21 PM