Академический Документы
Профессиональный Документы
Культура Документы
Number
:
Headin
g:
SQL Server
Questio
n:
Answer:
Level:
SE/SSE
Number:
Heading:
SQL Server
Question:
Answer:
Comment
s:
Level:
SE/SSE
Number:
Heading:
SQL Server
Question:
Answer:
Comment
s:
Level:
SE/SSE
Number:
Heading:
SQL Server
Question:
Answer:
Comment
s:
Level:
SE/SSE
Number
:
Headin
g:
SQL Server
Questio
n:
What are user defined datatypes and when you should go for them?
Answer:
User defined datatypes let you extend the base SQL Server datatypes by
providing a descriptive name, and format to the database. Take for
example, in your database, there is a column called Flight_Num which
appears in many tables. In all these tables it should be varchar(8). In this
case you could create a user defined datatype called Flight_num_type of
varchar(8) and use it across all your tables.
Level:
SE/SSE
Number:
Heading:
SQL Server
Question:
What is bit datatype and what's the information that can be stored
inside a bit column?
Answer:
Comment
s:
Level:
SE/SSE
Number:
Heading:
SQL Server
Question:
Answer:
Comment
s:
Level:
SE
Number
:
Headin
g:
SQL Server
Questio
n:
Answer:
Level:
SE/SSE
Number
:
Headin
g:
SQL Server
Questio
n:
Answer:
Level:
SSE/TL
Number:
10
Heading:
SQL Server
Question:
Answer:
Comment
s:
Level:
SSE/TL
Number
:
11
Headin
g:
SQL Server
Questio
n:
Answer:
Lock escalation is the process of converting a lot of low level locks (like
row locks, page locks) into higher level locks (like table locks). Every lock
is a memory structure too many locks would mean, more memory being
occupied by locks. To prevent this from happening, SQL Server escalates
the many fine-grain locks to fewer coarse-grain locks. Lock escalation
threshold was definable in SQL Server 6.5, but from SQL Server 7.0
onwards it's dynamically managed by SQL Server.
Level:
SSE/TL
Number
:
12
Headin
g:
SQL Server
Questio
n:
Answer:
Number:
13
Heading:
SQL Server
Question:
Answer:
Comment
s:
Level:
SE/SSE
Number:
14
Heading:
SQL Server
Question:
Whar is an index? What are the types of indexes? How many clustered
indexes can be created on a table? I create a separate index on each
column of a table. what are the advantages and disadvantages of this
approach?
Answer:
Indexes in SQL Server are similar to the indexes in books. They help
SQL Server retrieve the data quicker.
Comment
s:
Level:
SSE/TL
Number:
15
Heading:
SQL Server
Question:
Answer:
Comment
s:
Level:
SSE/TL
Number:
16
Heading:
SQL Server
Question:
What are the steps you will take to improve performance of a poor
performing query?
Answer:
This is a very open ended question and there could be a lot of reasons
behind the poor performance of a query. But some general issues
would be: No indexes, table scans, missing or out of date statistics,
blocking, excess recompilations of stored procedures, procedures and
triggers without SET NOCOUNT ON, poorly written query with
unnecessarily complicated joins, too much normalization, excess
usage of cursors and temporary tables.
Some of the tools/ways that help troubleshooting performance
problems are: SET SHOWPLAN_ALL ON, SET SHOWPLAN_TEXT ON, SET
STATISTICS IO ON, SQL Server Profiler, Windows NT /2000 Performance
monitor, Graphical execution plan in Query Analyzer.
Comment
s:
Level:
SSE/TL
Number:
17
Heading:
SQL Server
Question:
What is a deadlock and what is a live lock? How will you go about
resolving deadlocks?
Answer:
Comment
s:
Level:
SSE/TL
Number:
18
Heading:
SQL Server
Question:
What are statistics, under what circumstances they go out of date, and
how do you update them?
Answer:
Comment
s:
Level:
SSE/TL
Number:
19
Heading:
SQL Server
Question:
Answer:
There are lots of options available, you have to choose your option
depending upon your requirements. Some of the options you have are:
BACKUP/RESTORE, dettaching and attaching databases, replication,
DTS, BCP, logshipping, INSERT...SELECT, SELECT...INTO, creating
INSERT scripts to generate data.
Comment
s:
Level:
SSE/TL
Number:
20
Heading:
SQL Server
Question:
Answer:
Types of backups you can create in SQL Sever 7.0+ are Full database
backup, differential database backup, transaction log backup, filegroup
backup
Comment
s:
Level:
SSE/TL
Number:
21
Heading:
SQL Server
Question:
Answer:
Snapshot replication
Transactional replication (with immediate updating subscribers,
with queued updating subscribers)
Merge replication
Comment
s:
Level:
SSE/TL
Number:
22
Heading:
SQL Server
Question:
What are cursors? Explain different types of cursors. What are the
disadvantages of cursors? How can you avoid cursors?
Answer:
Comment
s:
Level:
SE/SSE
Number:
23
Heading:
SQL Server
Question:
Answer:
Joins are used in queries to explain how different tables are related.
Joins also let you select data from a table depending upon data from
another table.
Types of joins: INNER JOINs, OUTER JOINs, CROSS JOINs. OUTER JOINs
are further classified as LEFT OUTER JOINS, RIGHT OUTER JOINS and
FULL OUTER JOINS.
Number:
24
Heading:
SQL Server
Question:
Answer:
Comment
s:
Level:
SSE/TL
Number:
25
Heading:
SQL Server
Question:
Answer:
Comment
s:
Level:
SSE/TL
Number:
26
Heading:
SQL Server
Question:
What are triggers? How many triggers you can have on a table?
Answer:
In SQL Server 6.5 you could define only 3 triggers per table,
one for INSERT, one for UPDATE and one for DELETE. From SQL
Server 7.0 onwards, this restriction is gone, and you could
create multiple triggers per each action. But in 7.0 there's no
way to control the order in which the triggers fire. In SQL
Server 2000 you could specify which trigger fires first or fires
last using sp_settriggerorder
Triggers can't be invoked on demand. They get triggered only
when an associated action (INSERT, UPDATE, DELETE) happens
on the table on which they are defined.
Triggers are generally used to implement business rules,
auditing. Triggers can also be used to extend the referential
integrity checks, but wherever possible, use constraints for this
purpose, instead of triggers, as constraints are much faster.
Comment
s:
Level:
SE/SSE
Number:
27
Heading:
SQL Server
Question:
Answer:
Comment
s:
Level:
SSE/TL
Number:
28
Heading:
SQL Server
Question:
Answer:
Self join is just like any other join, except that two instances of the
same table will be joined in the query. Here is an example: Employees
table which contains rows for normal employees as well as managers.
So, to find out the managers of all the employees, you need a self join.
CREATE TABLE emp
(
empid int,
mgrid int,
empname char(10)
)
INSERT
INSERT
INSERT
INSERT
INSERT
emp
emp
emp
emp
emp
SELECT
SELECT
SELECT
SELECT
SELECT
1,2,'Vyas'
2,3,'Mohan'
3,NULL,'Shobha'
4,2,'Shridhar'
5,2,'Sourabh'
Comment
s:
Level:
SE/SSE
Number:
29
Heading:
SQL Server
Question:
Answer:
Comments:
Level:
SE/SSE
Number:
30
Heading:
SQL Server
Question:
Answer:
Comments:
Level:
SE/SSE
Number:
31
Heading:
SQL Server
Question:
Answer:
SQL Server supports temporary tables. These tables have names that
start with a number sign (#). If a temporary table is not dropped when
a user disconnects, SQL Server automatically drops the temporary
table. Temporary tables are not stored in the current database; they
are stored in the tempdb system database.
There are two types of temporary tables:
Comment
s:
Level:
SE/SSE
Number:
32
Heading:
SQL Server
Question:
Answer:
The master database records all of the system level information for a
SQL Server system. It records all login accounts and all system
configuration settings. master is the database that records the
existence of all other databases, including the location of the database
files. master records the initialization information for SQL Server;
always have a recent backup of master available.
Comment
s:
Level:
SE/SSE
Number:
33
Heading:
SQL Server
Question:
Answer:
Comment
s:
Level:
SE/SSE
Number:
34
Heading:
SQL Server
Question:
Answer:
The model database is used as the template for all databases created
on a system. When a CREATE DATABASE statement is issued, the first
part of the database is created by copying in the contents of the
model database, then the remainder of the new database is filled with
empty pages. Because tempdb is created every time SQL Server is
started, the model database must always exist on a SQL Server
system.
Comment
s:
Level:
SE/SSE
Number:
35
Heading:
SQL Server
Question:
Answer:
The msdb database is used by SQL Server Agent for scheduling alerts
and jobs, and recording operators.
Comment
s:
Level:
SE/SSE
Number:
36
Heading:
SQL Server
Question:
Answer:
Comment
s:
Level:
SE/SSE
Number:
37
Heading:
SQL Server
Question:
What is @@TRANCOUNT?
Answer:
Comment
s:
Level:
SE/SSE
Number:
38
Heading:
SQL Server
Question:
What is @@ERROR?
Answer:
Comment
s:
Level:
SE/SSE
Number:
39
Heading:
SQL Server
Question:
Answer:
Comment
s:
Level:
SE/SSE
Number:
40
Heading:
SQL Server
Question:
Answer:
Comment
s:
Level:
SE/SSE
Number:
41
Heading:
SQL Server
Question:
Answer:
When a user connects with a specified login name and password from
a nontrusted connection, SQL Server performs the authentication itself
by checking to see if a SQL Server login account has been set up and
if the specified password matches the one previously recorded. If SQL
Server does not have a login account set, authentication fails and the
user receives an error message.
Comment
s:
Level:
SE/SSE
Number:
42
Heading:
SQL Server
Question:
Answer:
The HAVING clause is then applied to the rows in the result set
that are produced by grouping. Only the groups that meet the
HAVING conditions appear in the query output. You can apply a
HAVING clause only to columns that also appear in the GROUP
BY clause or in an aggregate function.
Comment
s:
Level:
SE
Number:
43
Heading:
SQL Server
Question:
Answer:
Comment
s:
Level:
SE
Number:
44
Heading:
SQL Server
Question:
Answer:
Retrieve XML data using the SELECT statement and the FOR XML
clause.
To retrieve results directly, use the FOR XML clause of the SELECT
statement, and within the FOR XML clause, specify one of these XML
modes:
RAW
AUTO
EXPLICIT
These modes are in effect only for the execution of the query for which
they are set. They do not affect the results of any subsequent queries.
In addition to specifying the XML mode, you can also request the XMLData schema.
SELECT Customers.CustomerID, ContactName, CompanyName,
Orders.CustomerID, OrderDate
FROM Customers, Orders
WHERE Customers.CustomerID = Orders.CustomerID
AND (Customers.CustomerID = N'ALFKI'
OR Customers.CustomerID = N'XYZAA')
ORDER BY Customers.CustomerID
FOR XML AUTO
Comment
s:
Level:
SE/SSE
Number:
45
Heading:
SQL Server
Question:
Answer:
Comment
s:
Level:
SE/SSE
Number:
46
Heading:
SQL Server
Question:
Answer:
Comment
s:
Level:
SE/SSE
Number:
47
Heading:
SQL Server
Question:
Answer:
Comment
s:
Level:
SE/SSE
Number:
48
Heading:
SQL Server
Question:
What is the difference between Full text index and regular SQL Indexes?
Answer:
Full-text indexes
Stored under the control of the database Stored in the file system, but administered
in which they are defined.
through the database.
Several regular indexes per table are
allowed.
Not grouped.
Comment
s:
Level:
SE/SSE
Number:
49
Heading:
SQL Server
Question:
Answer:
A word or phrase.
SELECT ProductName
FROM Products
WHERE CONTAINS(ProductName, ' "sasquatch ale" OR "steeleye stout"
')
Comment
s:
Level:
SE/SSE
Number:
50
Heading:
SQL Server
Question:
Answer:
Comment
s:
Level:
SE/SSE
Number:
51
Heading:
SQL Server
Question:
Answer:
Outer joins. Outer joins can be a left, a right, or full outer join.
Outer joins are specified with one of the following sets of
keywords when they are specified in the FROM clause:
Cross joins.
Cross joins return all rows from the left table, each row from the
left table is combined with all rows from the right table. Cross joins
are also called Cartesian products.
Comment
s:
Level:
SE/SSE
Number:
52
Heading:
SQL Server
Question:
Answer:
Comment
s:
Level:
SE/SSE