Professional Documents
Culture Documents
SQL Interview
SQL Interview
14) What is the difference between UNION ALL Statement and UNION
The main difference between UNION ALL statement and UNION is UNION All statement
is much faster than UNION,the reason behind this is that because UNION ALL stat
ement does not look for duplicate rows, but on the other hand UNION statement do
es look for duplicate rows, whether or not they exist.
17) SQL Server runs on which TCP IP port and From where can you change the defau
lt port
SQL Server runs on port 1433 but we can also change it for better security and F
rom the network Utility TCP/IP properties -->Port number.both on client and the
server.
22) Define basic functions for master and msdb and tempdb databases in Sql Serve
r
(1)master:-It contains system level information for a SQL Server system and als
o contains login accounts and all system configuration settings. master is the d
atabase that records the existence of all other databases, including the locatio
n of the database files.
(2) tempdb - This database holds all temporary tables and temporary stored proce
dures. It also fills any other temporary storage needs such as work tables gener
ated by SQ
L Server. tempdb is re-created every time SQL Server is started so the system st
arts with a clean copy of the database.
(3)model - 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 d
atabase is created by copying in the contents of the model database, then the re
mainder of the new database is filled with empty pages. Because tempdb is create
d every time SQL Server is started, the model database must always exist on a SQ
L Server system.
(4)msdb - The msdb database is used by SQL Server Agent for scheduling alerts an
d jobs, and recording operators.
What is a constraint?
Constraints in Microsoft SQL Server 2000/2005 allow us to define the ways in whi
ch we can automatically enforce the integrity of a database. Constraints define
rules regarding permissible values allowed in columns and are the standard mecha
nism for enforcing integrity. Using constraints is preferred to using triggers,
stored procedures, rules, and defaults, as a method of implementing data integri
ty rules. The query optimizer also uses constraint definitions to build high-per
formance query execution plans.