Professional Documents
Culture Documents
and max server memory settings. (1) Win. Server 2003 SE supports
utpo 4GB (2) EE upto 32GB. (3) DC upto 64GB)
To Configure AWE:- Right click on instance > Properties > Memory >
Enable AWE > Set Min and Max memory etc.
Note:- AWE is not needed and cannot be configured on 64-bit operating
systems.
12) What is Linked Server? How to connect Linked server? How to test
linked Server?
One server connected with another server to execute queries against OLE DB
data sources on remote servers.
OLEDB Provider:- An OLE DB provider is a DLL that manages and interacts
with a specific data sources such as SQL Server 7.0, Access, Excel, ODBC,
Oracle, DB2, Local file system, Exchange Server etc. SQL Native Client
(PROGID: SQLNCLI) is the official OLE DB provider for SQL Server.
To connect linked server using OLE DB provider:sp_addlinkedserver
@server=servername,
@srvproduct=SQL
Server/Oracle
Tests the connection to a linked server:sp_testlinkedserver <servername>
13) What is purpose of Registered Servers?
Registering a server to store the server connection information for future
connections.
14) What do you mean by Collation?
Collation is basically the sort order. There are three types of sort orders
(1) Dictionary case sensitive , (2) Dictionary case insensitive, (3) Binary
15)
What are the Protocols used in Networking? What is the
Default Port number of TCP/IP?
The protocols used in networking are TCP/IP, NAMED PIPPES, VIA, SHARED
MEMORY. The default port no of TCP/IP is 1433.
16)
What is the Syntax used for find the SQL Server version?
1) Select @@version
2) Click on Server > Summary Reports > Server Dashboard > configuration
details > See product version.
17) What is blocking? How to identify and resolve the blockings?
Blocking happens when one user holds an exclusive lock on an object and a
second user requires an exclusive lock on the same object. This forces the
second user to wait, block on the first.
Determine Blocking sessions:- Activity Monitor, sp_who2, sp_lock,
sys.sysprocess, sys.dm_exec_requests, sys.dm_os_waiting_tasks
Resolve Blocking Session:- (1) Right click on session and Kill in Activity
Monitor (2) Kill Session_id
18) What is Deadlock?
A deadlock occurs when users try to place exclusive locks on each others
objects.
Ex:- User1 places an exclusive lock on Table1 and then tries to place an
exclusive lock on Table2. User2 already has an exclusive lock on table2, and
User2 tries to put an exclusive lock on Table1. This condition causes endless
loop of waiting for the locks to be released.
The Database engine picks one of the victim (users) and kills their
query and send a error message to users You are the victim of a deadlock
and try again later.
Deadlock Information Tools
1) Trace Flags:- DBCC TRACEON (1204) & DBCC TRACEON (1222). When
these trace flags is enabling, the deadlock information captured by the
SQL Server error log.
2) Deadlock graph event in SQL Profiler:- SQL Server Profiler graphically
representation of tasks and resources involved in a deadlock.
(Lock:Deadlock and Lock:Deadlock chain events in the Locks events)
3) System View:- We can find the blocking sessions by writing the following
query
Select session_id, status, blocking_session_id from sys.dm_exec_requests
where blocking_session_id > 0
Resolving Deadlock:- After find the session causing the problem we can
use KILL command.
> KILL process_id
19) What are the Types of Locks? Explain each?
There are 7 locks types are available in SQL Server 2005.
a) Shared Lock:- Shared (S) locks allow concurrent transactions to read
(SELECT) a resource under pessimistic concurrency control.
b) Update Lock:- Used on resources that can be updated. Prevents a
common form of deadlock that occurs when multiple sessions are reading,
locking, and potentially updating resources later.
c) Exclusive Lock:- Exclusive (X) locks prevent access to a resource by
concurrent transactions
d) Intent Lock:- Used to establish a lock hierarchy. The types of intent locks
are: intent shared (IS), intent exclusive (IX), and shared with intent
exclusive (SIX).
e) Schema:- Used when an operation dependent on the schema of a table is
executing.
f) Bulk Update:- Used when bulk copying data into a table and the
TABLOCK hint is specified
g) Key-Range:- Protects the range of rows read by a query when using the
serializable transaction isolation level
20)
What are the Components can be installed with SQL Server
2005?
We can install the following components with Microsoft SQL Server 2005
a) SQL Server Database Engine
b) Analysis Services
c) Reporting Services
d) Notification Services
e) Integration Services
f) Management Tools
g) Documentation and Samples
21)
What are the SQL Server Editions of SQL Server 2005?
SQL Server 2005 is available in 32-bit and 64-bit editions.
a) SQL Server 2005 Enterprise Edition (32-bit and 64-bit)
b) SQL Server 2005 Evaluation Edition (32-bit and 64-bit)
c) SQL Server 2005 Standard Edition (32-bit and 64-bit)
d) SQL Server 2005 Workgroup Edition (32-bit only)
e) SQL Server 2005 Developer Edition (32-bit and 64-bit)
f) SQL Server 2005 Express Edition (32-bit only)
g) SQL Server 2005 Compact Edition (32-bit only)
h) SQL Server 2005 Runtime Edition (32-bit and 64-bit)
22)
What is the process of Installation?
a) Prepare Your Computer to Install SQL Server 2005:- To prepare your
computer for SQL Server 2005, review hardware and software
requirements, System Configuration Checker requirements and blocking
issues, and security considerations.
b) Install SQL Server 2005:- To install SQL Server 2005, run Setup using
the SQL Server 2005 Installation Wizard or install from the command
prompt. You can also add components to an instance of SQL Server 2005,
or upgrade to SQL Server 2005 from a previous SQL Server version.
c) Configure Your SQL Server 2005 Installation:- After Setup completes
the installation of SQL Server 2005, you can configure SQL Server using
graphical and command prompt utilities
23)
What is the Virtual Memory? How to assign virtual memory &
how much space required for Virtual memory?
A reserved disk space to maintain transactions whenever Memory (RAM) is
full. Virtual memory size is at least 3 times of the physical memory installed
in the computer.
To Set Virtual memory:- Right click on System > Select System Properties
> Advanced > Performance Settings > Advanced > Virtual memory >
Change > Select directory > Provide min and max values.
DATABASE
1) What is Database? What are the files created while creating a
Database?
A Database is a collection of meaningful and related data that are stored in row
and columns format (Tables). While creating a Database in SQL Server there are
two data files are created called master data file (.mdf), log data file (.ldf) and
we can add one or more optional N-Dimensional data files (.ndf).
2) Explain about Data files (.mdf, .ndf, .ldf) (File structure)?
a) Primary Data file (.ldf):- Primary data files holds user data and objects.
Every database has one primary data file.
b) Secondary Data file (.ndf):- Secondary Data file (.ndf) is optional and hold
user data and objects that do not fit in the Primary data file. We can add N no.
of Secondary data files for a DB.
c) Log Data file (.ldf):- T.Log records all the transactions and database
modifications made by each transaction and it is used to recover the
database. At least one transaction log file required for each DB. Min. log file
size is 512 KB.
3) How store the data in SQL Server? What is Page and Page size? What is
Extent and Extent size?
The fundamental unit of data storage in SQL server is the PAGE. The size of the
page is 8 kb. Collection of eight contiguous pages is known as an EXTENT. The
size of an extent is 64 kb (8x8).
4) What is Fill factor? How to assign Fill factor?
A Fill factor is a reserved free space on each leaf level page which is used for
future growth of data or index in a table and reduces the page splits.
Assign Fill Factor:- Right Click on Server > Properties > Database Settings >
Default Index Fill Factor > Provide the value
5) Tell me about System Database and User Databases in 2000 and 2005?
SQL Server 2000:- 1) Master 2) Model 3) MSDB 4) TempDB
SQL Server 2005:- 1) Master 2) Model 3) MSDB 4) TempDB 5) Resource DB
6) Explain about System Databases in SQL Server 2005?
There are five system databases available in SQL Server 2005.
a) Master Database:- Records Server level objects such as Login Accounts, End
Points, Linked Servers, System Configuration settings, location of the
database files and initialization information for SQL server. SQL Server Cannot
starts if Master DB is unavailable.
b) Model Database:- The Model DB is used as a template for all databases
created on instances of SQL Server. If we create a new Database the Model
DB structure will be inherited to new Database.
c) MSDB Database:- The msdb database is used by SQL Server Agent for
scheduling alerts and jobs and by other features such as Service Broker and
Database Mail. SQL Server automatically maintain completed online backup
and restore history in MSDB.
d) TempDB:- Temp DB is a global resource DB. It stores user objects (global or
local temporary tables, stored procedures, table variables, or cursors),
Internal objects (intermediate results for spools or sorting) and versions
(online index operations, Multiple Active Result Sets (MARS), and AFTER
triggers). We cannot backup the Temp DB because when SQL Server Start (or)
Stop the Temp DB can be deleted permanently (or) refresh Temp DB.
e) Resource Database :- The Resource database is a hidden (read-only)
database that contains all the system objects such as sys.objects that are
included with SQL Server 2005. The Resource database makes upgrading
process easier and faster.
structures, such as B-tree indexes (or) double linked lists must be correct at
end of transaction.
c) Isolation:- Modifications made by concurrent transactions must be isolated
from the modifications made by the other consequent transactions. A
transaction either sees a data in the state it was in before another concurrent
transaction modified it, (or) sees the data after second transaction
completed.
d) Durability:- After a transaction has completed, its effects are permanently in
place in the system. The modification persists even in the event of a system
failure.
25)
Recovery Models
1) What is Recovery Model? Benefits of Recovery Models?
A recovery model is a Database property that control the basic behavior of
the backup and restore operations for a DB. Recovery models are designed
to control transaction log maintenance.
2) Explain Full, Bulk-Logged & Simple Recovery Models?
a) Full:- With Full Recovery Model we can recover the data up to the minute
of crash, because it records every operation in the transaction log.
a) Bulk-Logged:- With Bulk-Logged recovery model we can recover most of
the data, but we will lost bulk-operations because those are not recorded
in to the log. We can set this option just before performing a bulk insert
operation to speed up the bulk insert.
b) Simple:- With Simple Recovery Model we can recover the data only up to
the last backup, because nothing is recorded in the transactional log. Any
changes made to database after the last backup was performed will be lost
because they are not recorded in the transaction log. Generally it is useful
for test and development databases or data warehouses, but it is not
appropriate choice for Production Database.
3) Which DBs can we use Simple Recovery Model?
Simple Recovery Model is useful for Development, Test databases, Data
warehouses or not often changed Databases.
4) In Which Recovery Models Point-in-time recovery is possible?
10
11
12
Logshipping
1) What is Log shipping and purpose of Log shipping?
To achieve high availability and high protection, Log shipping copies
transactions from a primary server to one or more secondary servers. In Log
shipping, T.Log backups are sent to one or more secondary servers and then
restored to the destination servers individually. If the Primary database
becomes unavailable, any of the secondary database can brought into online
manually. The Secondary server acts as a Backup server and provides read-only
query processing to reduce the load on the Primary server. (For query
processing, secondary servers should be configure in stand-by mode).
2) What is Primary Server, Secondary Server & Monitor Server?
a) Primary Server: - Primary Server is a Production server which holds the
original copy of the database. Log shipping configuration and administrating
will be done from Primary Server.
b) Secondary Server: - Secondary servers hold the standby copy of the
database. We must initialize the DB on a secondary server by restoring a
backup from the Primary server using either NORECOVERY option or the
STANDBY option. By using STANDBY option Users can have read-only access
to it.
c) Monitor Server: - An optional Server is called as Monitor Server that
records history and status of backup, copy and restore operations and raises
alerts if any operations fail. The Monitor Sever should be on separate server
to avoid losing critical information. Single Monitor Server monitors multiple
Log shipping configurations.
3) What are the Jobs running for Log shipping and explain them?
Log shipping having four operations which are handled by SQL Server Agent Job.
a) Backup Job: - Backup job is created on Primary Server instance and it
performs backup operation. It logs history on the local server and monitor
severs and deletes old backup files and history information.
b) Copy Job: - Copy Job is created on Secondary server instance and it performs
copies the backup files from primary sever to secondary server. It logs history
on the secondary server and monitor server.
13
c) Restore Job: - Restore Job is created on the Secondary server instance and it
performs restore operation. It logs history on the local server and monitor
sever and deletes old files and history information.
d) Alert Job: - If a Monitor Server is used, the Alert Jobs is created on the
Monitor server instance and it raises Alerts if any operations have not
completed successfully.
4) Requirements for Log shipping?
a) SQL Server 2005 Standard Edition, Workgroup Edition, or Enterprise Edition
must be installed on all server instances involved in log shipping.
b) All servers should have the same case sensitivity settings.
c) The databases must use the full recovery model or bulk-logged recovery
model.
5) How to configure Log shipping?
a. Choose Primary Server, Secondary Servers, and optional Monitor server.
b. Create a File share to keep Transaction log backups (Best to place on a
separate computer)
c. Create a folder for each Secondary server into which transaction log backup
copies.
d. Choose Backup Schedule for Primary Database
e. Choose Copy and Restore Schedules for Secondary Database
f. Choose Alert Job schedule for Monitor Server if configured
6) What are permissions required for Log shipping?
We must have sysadmin on each server instance to configure Log shipping.
7) In Logshipping which Recovery Models can we used?
We can use either full or bulk logged recovery model for log shipping.
8) Where you monitoring Log shipping and how?
We can monitoring the Log shipping in the following ways.
a) Monitor server (History Tables):- Monitor Server tracks all statistics, status
and errors that could be happen during Log shipping.
1) Log_shipping_monitor_primary:- Stores primary server status
2) Log_shipping_monitor_secondary:- Stores secondary servers status
3) Log_shipping_monitor_history_detail:- Contains history details for
logshipping agents.
4) Log_shipping_monitor_error_detail:- Stores error details for log shipping
jobs.
5) Log_shipping_monitor_alert:- Stores Alert Job ID
b) System Stored Procedures (MSDB):- System Stored procedures gives the
history information about the specified server that are configured in Log
shipping.
1) sp_help_log_shipping_monitor (Run at Monitor Server)
2) sp_help_log_shipping_monitor_primary @Primary_Database = DBName
(Run at MS)
3) sp_help_log_shipping_monitor_secondary
@
Secondary_Database
=
DBName (Run at MS)
14
15
16
14)
How to monitoring Mirroring?
There are six methods are available for monitoring the Database Mirroring
a) SQL Server Management Studio:- A green arrow on the mirror server is
indicates running well. A red arrow indicates problems that need to
investigate.
b) SQL Server Log:- It provides information of Mirroring establishment and
status. If any errors occurs it will be logged to SQL Server log and Windows
event log.
c) Performance Monitor:- It can provides real-time information about
Database mirroring. We can use performance counters to get status of the
database mirroring such as Bytes received/sec, Bytes sent/sec, Transaction
delay etc.
d) Profiler:- Profiler many events are providing the status of the Database
mirroring
e) Database Mirroring Monitor:- Database Mirroring Monitor is a GUI tool
that shows update status and to configure warning thresholds.
To open DM Monitor:- Right click on Principal Database > Tasks > Select
Launch Database Mirroring Monitor.
f) System Stored Procedures:2. sp_dbmmonitoraddmonitoring
3. sp_dbmmonitorchangemonitoring
4. sp_dbmmonitorhelpmonitoring
5. sp_dbmmonitordropmonitoring
17
15)
What is Hardening?
As quickly as possible, the log buffer is written to the transaction log on disk,
a process called hardening.
16)
What is Log buffer
A log buffer is a special location in memory (RAM). SQL Server stores the
changes in the databases log buffer.
17)
How to Set a Witness Server to Database Mirroring?
SSMS:- Right Click on Principal Database > Tasks > Mirror > Click on
Configure Security > Provide the End point for Witness server > Click oK
T-SQL:ALTER
DATABASE
AdventureWorks
SET
WITNESS
=
'TCP://prasad.local:5024' (Do this from the Principal Server)
18)
How to Remove a Witness Server from Database Mirroring?
SSMS:- Right Click on Principal Database > Tasks > Mirror > Remove TCP
address from the Witness > Click oK
T-SQL:- ALTER DATABASE AdventureWorks SET WITNESS OFF
19)
How to Setup Fully Qualified Names for Database Mirroring?
I. FQDN Error
One or more of the server network addresses lacks a fully qualified domain
name (FQDN). Specify the FQDN for each server, and click Start Mirroring
again.
The syntax for a fully-qualified TCP address is:
TCP://<computer_name>.<domain_segment>[.<domain_segment>]:<port>
18
20)
1)
3)
4)
PENDING_FAILOVER:This state is found only on the principal server after a failover has
begun, but the server has not transitioned into the mirror role.
When the failover is initiated, the principal database goes into the
PENDING_FAILOVER state, quickly terminates any user connections, and
takes over the mirror role soon thereafter.
5)
DISCONNECTED:The partner has lost communication with the other partner
Replication
1)
What is Replication?
Replication is the process of copying and distributing data between databases
to different servers throughout the enterprise.
Replication is a set of technologies for copying and distributing data and
database objects from one database to another and then synchronizing between
databases to maintain consistency.
2)
19
4)
Explain about Publisher, Subscriber and Distributer?
a) Publisher:- The Publisher is a database that makes data available for
replication. The Publisher can have one or more publications.
b) Distributor:- The distributor is the intermediary between the publisher and
subscriber. It receives published transactions or snapshots and then stores and
forwards these publications to the subscribers.
c) Subscribers:- Subscribers are database servers that store the replicated
data and receive updates. A subscriber can receive data from multiple
publishers. Based on the replication type, the Subscriber can also pass data
changes back to the Publisher or republish the data to other Subscribers.
5)
Explain about Article, Publication, Subscription?
a) Article:- An Article is the data, transactions, or stored procedures that are
stored within a publication. This is the actual information that is going to be
replicated.
b) Publication:- The publication is the storage container for different articles. A
subscriber can subscribe to an individual article or an entire publication.
20
21
MANAGEMENT
1)
What is Maintenance Plan?
Maintenance plans create a workflow for database optimization, and make free
from inconsistencies.
2) What the tasks in Maintenance Plans?
3) SQL Server Logs?
4)
Database Mail?
Database Mail is an enterprise solution for sending e-mail messages from the
Microsoft SQL Server 2005 Database Engine. Using Database Mail, your database
applications can send e-mail messages to users. The messages can contain
22
query results, and can also include files from any resource on your network.
Database Mail is designed for reliability, scalability, security, and supportability.
5) Full Text Search?
PERFORMANCE TUNING
1) Which Tools are used for Performance Tuning?
There are many tools are used for Performance tuning
a) Windows tools for monitoring applications:- Performance monitor,
Performance Counters and Logs, Task manager, Network manager
b) SQL Server tools for monitoring components:- SQL trace, SQL
Profiler, DMVs, System Stored procedures, Graphical show plan, Activity
Monitor, DBCC, Built-in Functions, Trace flags
2) How to identify longest running queries?
There are two ways to identify slow running queries
1) Profiler (By using duration of the query)
2) sys.dm_exec_query_stats and sys.dm_exec_requests DMVs
3) DBCC OPENTRAN
3) Reasons for Slow Running Query?
There are a number of common reasons for slow-running queries
a) Lack of useful indexes, Lack of useful data striping (RAID).
b) Blockings, Table scans, Lack of useful partitioning
c) Missing or out of date statistics (update statistics)
d) Slow network communication.
e) Insufficient memory available for SQL Server.
f) Insufficient disk space.
g) Excess recompilations of Stored Procedures
h) Procedures and Triggers without SET NOCOUNT On
4) How to analyze query performance?
We can analyze query performance in three ways
1) T-SQL:- SET SHOWPLAN_ALL ON/OFF, SET SHOWPLAN_TEXT ON/OFF
2) SSMS:- Estimated Execution Plan & Actual Execution plan
3) Profiler:- To display text and XML execution plans, see Displaying
Execution Plans by Using SQL Server Profiler Event Classes
5) How to increase Query performance?
We can improve query performance in the following ways
1) Add indexes if required
2) Run Update statistics for out of date statistics
3) Resolving Blocking issues
4) Add space to DB files or TempDB, if that are not having enough space
5) Reduce the too much normalization
6) Using Temporary tables instead of Cursors
7) SPs and Triggers are with Set NOCOUNT On
23
24
10)
What is DAC? How to connect DAC?
DAC is stands for Dedicated Administrator Connection. This diagnostic
connection allows an administrator to access running instance to
troubleshoot problems or execute diagnostic queries on the server - even
when SQL Server is not responding to standard connection requests. This
connection uses 1434 port and can connect only one connection per
instance.
To connect DAC:1) SQLCMD:- -Sadmin:<instance_name>
2) GUI:- SSMS Query Editor by connecting to ADMIN:<instance_name>
11)
Explain about Database Console Commands (DBCC)?
DBCC Commands are used to check the consistency of the Databases or
Database Objects. While executing DBCC commands the DB engine creates a
database snapshot and then runs the checks against this snapshot. After the
DBCC command is completed, this snapshot is dropped.
12) What is Stored Procure? What are the types of stored Procedures
available in SQL server and explain each?
A stored procedure is a precompiled executable object that contains one
or more Transact-SQL statements.
a) User Defined Stored Procedure:- Stored procedures are modules or
routines that encapsulate code for reuse. A stored procedure can take
input parameters, return tabular or scalar results and messages to the
client
b) System Stored Procedure:- System stored procedures are used to
perform many administrative and informational activities.
c) Extended stored procedure:- Extended stored procedures are used to
create own external routines in a programming language such as C.
Extended stored procedures are DLLs that an instance of Microsoft SQL
Server can dynamically load and run.
13) What is Activity Monitor and use of that? What are the permissions
required to use Activity Monitor?
Activity Monitor is used to get information about users connections to the
Database Engine and the locks that they hold. Activity Monitor is used to
troubleshooting database locking issues, and to terminate a deadlocked or
unresponsive process.
To use activity monitor:- VIEW SERVER STATE permission on Server
and SELECT permission to the sysprocesses & syslocks tables in the
master database.
To Kill a Process:- sysadmin and processadmin database roles and
permission are required to KILL a process.
14) What is Execution Plan and explain it?
Execution Plan graphically displays the data retrieval methods chosen by
SQL Server. It represents the execution cost of specific statements and
queries in SQL Server. This graphical approach is very useful for
understanding the performance of the query.
25
26
18)
What is Severity level in Event log? At what severity levels are
written to the SQL Server log?
The Severity level tells how bad the error is. Above 19 Severity level errors
are written to the SQL Server log.
19)
What is State Attribute of an error message in Event log?
The state attributes provides details of what caused the error.
20)
What are the Causes of Physical Server Failures?
There are five common issues will causes Physical Server failures.
1) Disk failures
2) Memory failures
3) Processor failures
4) Network card failures
5) RAID failures
21)
If Log file is full what you will do?
If the T.Log file is full the Database issues 9002 error and it is in Read-only
state and will not allow updates.
The following tasks will responding T.Log file
1) Backing up the log
2) Adding one or more log files
3) Moving the Log to another disk
4) Increasing log file size or enabling auto growth
5) Teminating long-running transactins.
22)
If Data file is full what you will do?
If the primary data file is full we can add secondary data files.
Adding a file to database: - Right click on database > Properties > Files >
click add > give the values for logical name, file type, file group, initial size,
auto growth, path and file name .
23)
If a Database is under Suspect mode? What you will do?
sp_resetstatus:- Resets the status of a suspect database (sp_resetstatus
Adventureworks)
24)
If the server has completely failed, and how to all the backups
restored onto a new server?
a) Build the Windows server and restore the domain logins to support
Windows authentication.
b) Install SQL Server and any service-pack upgrades.
c) Put SQL Server in single-user mode and restore the master database.
d) Restore the msdb database.
e) If the model database was modified, restore it.
f) Restore the user databases.
25)
If a Server performance is slow? How you can troubles shoot a
problem?
27
26)
If a Database Performance is slow? How can you do Performance
Tuning?
27)
What are the Performance Issues? Explain them?
MISCELLANEOUS
1) What are the Differences between Delete & Truncate?
Delete:- Delete command removes the rows in a table and records in
transaction log which makes it slow. Rollback is possible.
Truncate:- Truncate command removes all the rows in a table, but it wont
write log which makes it faster. Rollback is not possible.
2) What is an Index? Types of Indexes? How many clustered indexes
and non-clustered indexes created on a table?
Generally SQL Server examines (table scan) every row in the table to satisfy
the query results. Index is a physical structure containing pointers to the
data which is used for retrieving data more quickly and improves the query
performance.
Clustered Index:- Only one Clustered index can create on a Table. When we
create a clustered index on a table, all the rows in the table are stored in the
order of the clustered index key.
Non-clustered index:- 249 Non-Clustered indexes can create on a Table.
Non-clustered indexes are stored as B-Tree structures with the leaf level
nodes having the index key and its row locator.
3) How can we rebuild an Index?
By using DBCC DBREINDEX
4) What's the difference between a primary key and a unique key?
Both primary key and unique key enforces uniqueness of the column on
which they are defined.
S
l
1
2
Primary Key
Unique Key
28
8) What is a Trigger? What are the trigger models are available in SQL
Server 2005?
29
12)
What is the difference between a Local and a Global temporary
table?
30
Local temporary table:- It exists only for the duration of a connection or, if
defined inside a compound statement, for the duration of the compound
statement.
Global temporary table:- remains in the database permanently, but the
rows exist only within a given connection. When connection is closed, the
data in the global temporary table disappears. However, the table definition
remains with the database for access when database is opened next time.
13)
What is PRIMARY KEY?
A PRIMARY KEY constraint is a unique identifier for a row within a database
table. Every table should have a primary key constraint to uniquely identify
each row and only one primary key constraint can be created for each table.
The primary key constraints are used to enforce entity integrity.
14)
What is UNIQUE KEY constraint?
A UNIQUE constraint enforces the uniqueness of the values in a set of
columns, so no duplicate values are entered. The unique key constraints are
used to enforce entity integrity as the primary key constraints.
15)
What is FOREIGN KEY?
A FOREIGN KEY constraint prevents any actions that would destroy links
between tables with the corresponding data values. A foreign key in one
table points to a primary key in another table. Foreign keys prevent actions
that would leave rows with foreign key values when there are no primary
keys with that value. The foreign key constraints are used to enforce
referential integrity.
16)
What is CHECK Constraint?
A CHECK constraint is used to limit the values that can be placed in a
column. The check constraints are used to enforce domain integrity.
17)
What is NOT NULL Constraint?
A NOT NULL constraint enforces that the column will not accept null values.
The not null constraints are used to enforce domain integrity, as the check
constraints.