Lost universe of Programing
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Lost universe of Programing

USERNAME :- Forum Post:-114
 
HomePortalGalleryLatest imagesRegisterLog in

 

 SQL Interview questions

Go down 
AuthorMessage
Administrator
Admin
Admin
Administrator


Male
Number of posts : 160
Age : 38
Location : Lucknow
Job/hobbies : Software Engeener
What U like To do ? : Because Its Rock with me.
Registration date : 2008-01-06

SQL Interview questions Empty
PostSubject: SQL Interview questions   SQL Interview questions I_icon_minitime5/11/2008, 12:25 pm

Can a stored procedure call itself or recursive stored procedure? How many
levels SP nesting possible?
Yes. Because Transact-SQL supports recursion, you can write stored
procedures that call themselves. Recursion can be defined as a method of
problem solving wherein the solution is arrived at by repetitively applying it
to subsets of the problem. A common application of recursive logic is to
perform numeric computations that lend themselves to repetitive evaluation by
the same processing steps. Stored procedures are nested when one stored
procedure calls another or executes managed code by referencing a CLR routine,
type, or aggregate. You can nest stored procedures and managed code references
up to 32 levels.

What is @@ERROR?The @@ERROR automatic variable returns the error code of the last
Transact-SQL statement. If there was no error, @@ERROR returns zero. Because
@@ERROR is reset after each Transact-SQL statement, it must be saved to a
variable if it is needed to process it further after checking it.

What is Raise error? Stored procedures report errors to client applications via the RAISERROR
command. RAISERROR doesn’t change the flow of a procedure; it merely displays
an error message, sets the @@ERROR automatic variable, and optionally writes
the message to the SQL Server error log and the NT application event log.

What is log shipping?Log shipping is the
process of automating the backup of database and transaction log files on a
production SQL server, and then restoring them onto a standby server.
Enterprise Editions only supports log shipping. In log shipping the
transactional log file from one server is automatically updated into the backup
database on the other server. If one server fails, the other server will have
the same db can be used this as the Disaster Recovery plan. The key feature of
log shipping is that is will automatically backup transaction logs throughout
the day and automatically restore them on the standby server at defined
interval.


What is the difference between a local and a global variable?A local temporary table exists only for the duration of a connection
or, if defined inside a compound statement, for the duration of the compound
statement.

A 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.

What are the different types of replication? Explain.
The SQL Server
2000-supported replication types are as follows:



  • Transactional
  • Snapshot
  • Merge

Snapshot replication distributes data exactly as it
appears at a specific moment in time and does not monitor for updates to the
data. Snapshot replication is best used as a method for replicating data that
changes infrequently or where the most up-to-date values (low latency) are not
a requirement. When synchronization occurs, the entire snapshot is generated
and sent to Subscribers.

Transactional replication, an initial snapshot of
data is applied at Subscribers, and then when data modifications are made at
the Publisher, the individual transactions are captured and propagated to
Subscribers.

Merge replication is the process of distributing
data from Publisher to Subscribers, allowing the Publisher and Subscribers to
make updates while connected or disconnected, and then merging the updates
between sites when they are connected.

What are the OS services that the SQL Server installation adds?
MS SQL SERVER SERVICE, SQL AGENT SERVICE, DTC (Distribution transac
co-ordinator)

What are three SQL keywords used to change or set someone’s
permissions?

GRANT, DENY, and REVOKE.

What does it mean to have quoted_identifier on? What are the
implications of having it off?

When SET QUOTED_IDENTIFIER
is ON, identifiers can be delimited by double quotation marks, and literals
must be delimited by single quotation marks. When SET QUOTED_IDENTIFIER is OFF,
identifiers cannot be quoted and must follow all Transact-SQL rules for
identifiers.

What is the STUFF function and how does it differ from the REPLACE
function?

STUFF function to overwrite existing characters. Using this syntax, STUFF(string_expression,
start, length, replacement_characters), string_expression is the string that
will have characters substituted, start is the starting position, length is the
number of characters in the string that are substituted, and
replacement_characters are the new characters interjected into the string.
REPLACE function to replace existing characters of all occurance. Using this
syntax REPLACE(string_expression, search_string, replacement_string), where
every incidence of search_string found in the string_expression will be
replaced with replacement_string.

Using query analyzer, name 3 ways to get an accurate count of the
number of records in a table?

SELECT * FROM table1
SELECT COUNT(*) FROM table1
SELECT rows FROM sysindexes WHERE id = OBJECT_ID(table1) AND indid < 2

How to rebuild Master Database?
Shutdown Microsoft SQL Server 2000, and then run Rebuildm.exe. This is located
in the Program Files\\\\\\\\Microsoft SQL Server\\\\\\\\80\\\\\\\\Tools\\\\\\\\Binn directory.
In the Rebuild Master dialog box, click Browse.
In the Browse for Folder dialog box, select the \\\\\\\\Data folder on the SQL Server
2000 compact disc or in the shared network directory from which SQL Server 2000
was installed, and then click OK.
Click Settings. In the Collation Settings dialog box, verify or change settings
used for the master database and all other databases.
Initially, the default collation settings are shown, but these may not match
the collation selected during setup. You can select the same settings used
during setup or select new collation settings. When done, click OK.
In the Rebuild Master dialog box, click Rebuild to start the process.
The Rebuild Master utility reinstalls the master database.
To continue, you may need to stop a server that is running.
Source: http://msdn2.microsoft.com/en-us/library/aa197950(SQL.80).aspx

What is the basic functions for master, msdb, model, tempdb databases?
The Master database holds information for all databases located
on the SQL Server instance and is the glue that holds the engine together.
Because SQL Server cannot start without a functioning master database, you must
administer this database with care.
The msdb database stores information regarding database backups,
SQL Agent information, DTS packages, SQL Server jobs, and some replication
information such as for log shipping.
The tempdb holds temporary objects such as global and local
temporary tables and stored procedures.
The model is essentially a template database used in the creation
of any new user database created in the instance.

What are primary keys and foreign keys?
Primary keys are the unique identifiers for each
row. They must contain unique values and cannot be null. Due to their
importance in relational databases, Primary keys are the most fundamental of
all keys and constraints. A table can have only one Primary key.
Foreign keys are both a method of ensuring data
integrity and a manifestation of the relationship between tables.

What is data integrity? Explain constraints?
Data integrity is an important feature in SQL
Server. When used properly, it ensures that data is accurate, correct, and
valid. It also acts as a trap for otherwise undetectable bugs within
applications.
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.


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.


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.


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.


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.


What are the properties of the Relational tables?
Relational tables have six properties:


  • Values are atomic.
  • Column values are of the same
    kind.
  • Each row is unique.
  • The sequence of columns is
    insignificant.
  • The sequence of rows is
    insignificant.
  • Each column must have a
    unique name.

What is De-normalization?
De-normalization is the process of attempting to optimize the performance of a
database by adding redundant data. It is sometimes necessary because current DBMSs
implement the relational model poorly. A true relational DBMS would allow for a
fully normalized database at the logical level, while providing physical
storage of data that is tuned for high performance. De-normalization is a
technique to move from higher to lower normal forms of database modeling in
order to speed up database access.

How to get @@error and @@rowcount at the same time?
If @@Rowcount is checked after Error checking statement then it will have 0
as the value of @@Recordcount as it would have been reset.
And if @@Recordcount is checked before the error-checking statement then
@@Error would get reset. To get @@error and @@rowcount at the same time do both
in same statement and store them in local variable. SELECT @RC = @@ROWCOUNT,
@ER = @@ERROR

What is Identity?
Identity (or AutoNumber) is a column that automatically generates numeric
values. A start and increment value can be set, but most DBA leave these at 1.
A GUID column also generates numbers, the value of this cannot be controled. Identity/GUID
columns do not need to be indexed.

What is a Scheduled Jobs or What is a Scheduled Tasks?
Scheduled tasks let user automate processes that run on
regular or predictable cycles. User can schedule administrative tasks, such as
cube processing, to run during times of slow business activity. User can also
determine the order in which tasks run by creating job steps within a SQL
Server Agent job. E.g. Back up database, Update Stats of Tables. Job steps give
user control over flow of execution. If one job fails, user can configure
SQL Server Agent to continue to run the remaining tasks or to stop execution.

What is a table called, if it does not have neither Cluster nor
Non-cluster Index? What is it used for?
Unindexed table or Heap. Microsoft Press Books and Book On
Line (BOL) refers it as Heap.
A heap is a table that does not have a clustered index and, therefore, the
pages are not linked by pointers. The IAM pages are the only structures that
link the pages in a table together.
Unindexed tables are good for fast storing of data. Many times it is better to
drop all indexes from table and than do bulk of inserts and to restore those
indexes after that.

What is BCP? When does it used?
BulkCopy is a tool used to copy huge amount of data from tables and views. BCP
does not copy the structures same as source to destination.

How do you load large data to the SQL server database?
BulkCopy is a tool used to copy huge amount of data from tables. BULK
INSERT command helps to Imports a data file into a database table or view in a
user-specified format.

Can we rewrite subqueries into simple select statements or with joins?
Subqueries can often be re-written to use a standard outer join, resulting in
faster performance. As we may know, an outer join uses the plus sign (+)
operator to tell the database to return all non-matching rows with NULL values.
Hence we combine the outer join with a NULL test in the WHERE clause to
reproduce the result set without using a sub-query.

Can SQL Servers linked to other servers like Oracle?
SQL Server can be lined to any server provided it has OLE-DB provider from
Microsoft to allow a link. E.g. Oracle has a OLE-DB provider for oracle that
Microsoft provides to add it as linked server to SQL Server group.

How to know which index a table is using?
SELECT table_name,index_name FROM user_constraints

How to copy the tables, schema and views from one SQL server to another?
Microsoft SQL Server 2000 Data Transformation Services (DTS) is a set of
graphical tools and programmable objects that lets user extract, transform, and
consolidate data from disparate sources into single or multiple destinations.
Back to top Go down
https://aspx.forumotion.com
 
SQL Interview questions
Back to top 
Page 1 of 1
 Similar topics
-
» SQL Interview questions
» SQL Interview questions
» SQL Interview questions

Permissions in this forum:You cannot reply to topics in this forum
Lost universe of Programing :: --=| SOURCE CODE |=-- :: DATA BASE MANAGEMENT-
Jump to: