Friday, May 31, 2019

How to Shutdown or Restart Oracle RAC Database Server in 6 Steps

How to Shutdown or Restart Oracle RAC Database Server in 6 Steps ?

Sometimes DBA has to either Shutdown Oracle RAC Database Server or Restart Oracle RAC Database Server because of scheduled maintenance,OS patching, OS Upgrade and Hardware replacement etc. Since, Oracle products has evolved a lot so now there are many things to take care by Database Administrator before restarting or shutting down Database Server.
An Oracle Database Server can have following Oracle Components.

1. Oracle Database Running.
2. If RAC is configured. A cluster stack will also be running at the server.
3. If DBA is using ASM instance for Shared storage device. You will find an running ASM instance on the server.
4. A listener will be running there.
5. OEM Control, this is an optional component.

If you have all these components running on Database Server, then before restart or shutdown Database server you have to stop all these resource to avoid any corruption or inconsistency into database. 

Here I will discuss about restarting or shutting down only single server for Real Application cluster environment. So that Database is accessible through other nodes. Though DBA can also easily shutdown whole clusterware but this will make database unavailable So make sure you really need that.

6 Steps to Shutdown or Restart Oracle RAC Database Server

In this process, we have to follow a order of stopping resources. So when you apply steps given in this post use them in same order as written in the post.

1. Stop Database Instances: The process of shutdown or restart DB server starts with stopping the database instance running on database node. So, first of all DBA has to stop database instance running on this node. This will not make an impact on database since database is accessible through other instances in RAC env. Before stopping database instance make sure another instance is running other server.
[grid@db oracle]$ srvctl status database -d oradb
Instance oradb1 is running on node dbnode1
Instance oradb2 is running on node dbnode2

[grid@ oracle]$ srvctl stop instance -d oradb -i oradb1

[grid@ oracle]$ srvctl status database -d oradb
Instance oradb1 is not running on node dbnode1
Instance oradb2 is running on node dbnode2

Now Database oradb is running on dbnode2 having instance name oradb2. If this server has more than one database instance running on this node use same method to stop each instance.


2. Stop Services on Database Node: If you have configured some node level services on database node, then list and stop them using below:
[grid@ oracle]$ srvctl status service -d oradb -v
Service oltp is running on instance(s) dbnode1

[grid@ oracle]$ srvctl stop service -d oradb -s oltp

[grid@ oracle]$ srvctl status service -d oradb -v
Service oltp is not running.

In the above case, only one service is running on oradb1 instance, which is stopped now.


3. Stop Node level Applications: If DBA has some node level application configured then stop them using below:
[grid@ oracle]$ srvctl status nodeapps -n dbnode1
VIP dbnode1-vip is enabled
VIP dbnode1-vip is running on node: dbnode1
Network is enabled
Network is running on node: dbnode1
GSD is disabled
GSD is not running on node: dbnode1
ONS is enabled
ONS daemon is running on node: dbnode1

[grid@ oracle]$ srvctl stop nodeapps -n dbnode1 -f
PRKO-2426 : ONS is already stopped on node(s): dbnode1

[grid@ oracle]$ srvctl status nodeapps -n dbnode1
VIP dbnode1-vip is enabled
VIP dbnode1-vip is not running
Network is enabled
Network is not running on node: dbnode1
GSD is disabled
GSD is not running on node: dbnode1
ONS is enabled
ONS daemon is not running on node: dbnode1

4. Stop Running ASM Instances: ASM instance is a bridge between Database instance running on database node and database stored on shared server. In order to stop DB server DBA has to stop ASM instance as well.
[grid@ oracle]$ srvctl stop asm -n dbnode1-f

[grid@ oracle]$ srvctl status asm -n dbnode1
ASM is not running on dbnode1

5. Stop Listener on Database Server: Listener is used to listen requests coming for new connections, so before stooping database server we have to stop listener on the server so that it doesn't take new connection requests.
[grid@ oracle]$ srvctl status listener -n dbnode1
Listener LISTENER is enabled on node(s): dbnode1
Listener LISTENER is running on node(s): dbnode1

[grid@oracle]$ srvctl stop listener -n dbnode1

[grid@oracle]$ srvctl status listener -n dbnode1
Listener LISTENER is enabled on node(s): dbnode1
Listener LISTENER is not running on node(s): dbnode1

Now all components from database side are stopped, DBA can move forward to restart or shutdown database server. 6. Restart or shutdown database server: To shutdown or restart database server, DBA has to have root user login credentials. To Restart Linux Database Server. [root@oracle]$ /sbin/shutdown -r now To Shutdown database server. [root@oracle]$ shutdown -h now
If you not using RAC environment and want's to shutdown or Restart DB server, then just shutdown the database instance using "shutdown immediate"  and stop listener using "lsnrctl stop {listener_name}" and execute step 6 given in this post.

How to Shutdown Oracle Real Application Clusters Database

How to Shutdown Oracle Real Application Clusters Database ?

Here, We will start with stopping resources from Enterprise Manager Grid Control to Oracle Cluster ware or CRS process and will end at stopping CRS services. Here I am taking an example of Two node RAC database to perform all operations. Steps followed are as:
1. Shutdown Oracle Home process accessing database.
2. Shutdown RAC Database Instances on all nodes.
3. Shutdown All ASM instances from all nodes.
4. Shutdown Node applications running on nodes.
5. Shut down the Oracle Cluster ware or CRS.


1. Shutdown Oracle Home process accessing database: There could be oracle and non Oracle application which access database, So first step is to stop all the applications or DBA should inform application owner and he should stop all applications accessing Database. DBA should also stop Oracle application like Enterprise Manager Grid Control and Database Listener which access database for monitoring and database connections.

[oracle@database ~]$ emctl stop dbconsole

Oracle Enterprise Manager 11g Database Control Release 11.2.0.2.0 
Copyright (c) 1996, 2010 Oracle Corporation.  All rights reserved.
https://database.example.com:5500/em/console/aboutApplication
Stopping Oracle Enterprise Manager 11g Database Control ... 
 ...  Stopped. 

[grid@node1 bin]$ srvctl stop listener -n node1

[grid@node1 bin]$ srvctl status listener -n node1
Listener LISTENER is enabled on node(s): node1
Listener LISTENER is not running on node(s): node1

2. Shutdown RAC Database Instances on all nodes: Suppose DBA has two node RAC database, So he has to stop all instances from all DB nodes. Here, I am taking an example of two node RAC. First, I am checking on which server database is running and then stopping and verify for the same.

Syntax: srvctl stop database -d {databasename}

[oracle@node2 ~]$ srvctl status database -d oradb
Instance oradb1 is running on node node1
Instance oradb2 is running on node node2
[oracle@node2 ~]$ srvctl stop database -d oradb

[oracle@node2 ~]$ srvctl status database -d oradb
Instance oradb1 is not running on node node1
Instance oradb2 is not running on node node2

We just need to execute one command from any one of the server having database and it will stop all database instances on all servers. If you have more than one database configured on Nodes, then Database Administrator has to execute this command for each database.


3. Shutdown All ASM instances from all nodes: Next DBA has to shut down an ASM instance which are used to acess database, enter the following command, where node is the
name of the node where the ASM instance is running

Syntax: srvctl stop asm -n {node}

[grid@node2 oracle]# srvctl stop asm -n node1 -f

[grid@node2 oracle]# srvctl stop asm -n node2 -f

[grid@node2 oracle]# srvctl status asm -n node1
ASM is not running on node1

[grid@node2 oracle]# srvctl status asm -n node2
ASM is not running on node2

Sometimes, Database administrator face some issues in stopping ASM instance, In that case use "-f" option to forcefully shutdown ASM instances.


4. Shutdown Node applications running on nodes: To stop node applications running on a node, enter the following command, where node is the name of the node where the applications are running

[grid@node2 oracle]#  srvctl stop nodeapps -n node1 -f

[grid@node2 oracle]# srvctl status nodeapps -n node1 
VIP node1-vip is enabled
VIP node1-vip is running on node: node1
Network is enabled
Network is running on node: node1
GSD is disabled
GSD is not running on node: node1
ONS is enabled
ONS daemon is running on node: node1

Repeat same command for all nodes one by one. If you face any issue in stopping node applications use "-f" as force option to stop applications.


5. Shut down the Oracle Clusterware or CRS: In this command all CRS related process will be stopped. This is the only command which needs to be executed by "root" user on all database nodes.

[root@node1 bin]# crsctl check cluster -all

**************************************************************
node1:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online

*************************************************************
node2:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************

[root@node1 bin]# crsctl stop crs

CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'node1'
CRS-2673: Attempting to stop 'ora.crsd' on 'node1'
CRS-2790: Starting shutdown of Cluster Ready Services-managed resources on 'node1'
CRS-2673: Attempting to stop 'ora.LISTENER_SCAN2.lsnr' on 'node1'
CRS-2673: Attempting to stop 'ora.LISTENER.lsnr' on 'node1'
CRS-2673: Attempting to stop 'ora.LISTENER_SCAN3.lsnr' on 'node1'
CRS-2673: Attempting to stop 'ora.node2.vip' on 'node1'
-------------------------------------------------
-------------------------------------------------
-------------------------------------------------
CRS-2677: Stop of 'ora.cssd' on 'node1' succeeded
CRS-2673: Attempting to stop 'ora.gipcd' on 'node1'
CRS-2677: Stop of 'ora.gipcd' on 'node1' succeeded
CRS-2673: Attempting to stop 'ora.gpnpd' on 'node1'
CRS-2677: Stop of 'ora.gpnpd' on 'node1' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'node1' has completed
CRS-4133: Oracle High Availability Services has been stopped.

[root@node1 bin]# crsctl check cluster -all

CRS-4639: Could not contact Oracle High Availability Services
CRS-4000: Command Check failed, or completed with errors.

DBA can see Now RAC is completely down. Now you can move ahead with your patching, maintenance activity.  Next let's see how to start Oracle RAC cluster database.


How to Start Oracle Real Application Clusters Database ?


In Starting Real Application Clusters Database, We will also follow a set of sequence. The order will be just opposite to Shutting down the Real Application Clusters Database.

1. Start Oracle Clusterware or CRS.
2. Start Node applications running on nodes.
3. Start All ASM instances from all nodes.
4. Start RAC Database Instances on all nodes.
5. Start Oracle Home process accessing database.


1. Start Oracle Clusterware or CRS: CRS starts automatically when you start or restart Server, but Here DBA has manually shutdown the CRS So, he has to start it manually. This is the only command which needs to be executed by "root" user. Database Administrator should execute this command on all nodes.

[root@node1 bin]# crsctl start crs
CRS-4123: Oracle High Availability Services has been started 
[root@node2 bin]# crsctl check cluster -all
**************************************************************
node1:
CRS-4535: Cannot communicate with Cluster Ready Services
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************

node2:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************

Here, DBA can see "CRS-4639: Could not contact Oracle High Availability Services" or "CRS-4535: Cannot communicate with Cluster Ready Services" messages. Wait 5 minutes and then again check with "crsctl check cluster -all" command. This time Database administrator will get "CRS-4537: Cluster Ready Services is online". If still same issue DBA can start ora.crsd process to resolve this issue. Below is the command

[root@node1 bin]# crsctl start res ora.crsd -init

[root@node1 bin]# crsctl check cluster -all
**************************************************************
node1:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************

node2:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************

Now, Cluster is up and running. DBA can also use "ps -ef | grep d.bin" to check cluster status.


2. Start Node applications running on nodes: To start node applications running on a node, enter the following command, where node is the name of the node where the applications are running

[grid@node1 bin]$ srvctl start nodeapps -n node1

[grid@node1 bin]$ srvctl status nodeapps -n node1
VIP node1-vip is enabled
VIP node1-vip is running on node: node1
Network is enabled
Network is running on node: node1
GSD is disabled
GSD is not running on node: node1
ONS is enabled
ONS daemon is running on node: node1

DBA has to execute this command for each node to start Real Application Clusters Cluster database.


3. Start All ASM instances from all nodes: Next DBA has to start all ASM instances which are used to access database, enter the following command, where node is the name of the node where the ASM instance has to start.

[grid@node1 bin]$ srvctl start asm -n node1

[grid@node1 bin]$ srvctl status asm -n node1
ASM is running on node1

DBA has to start ASM instance on all database nodes.


4. Start RAC Database Instances on all nodes: Now, We will start database instances on database nodes to access data.

[grid@node1 bin]$ srvctl start database -d oradb

[grid@node1 bin]$ srvctl status database -d oradb
Instance oradb1 is running on node node1
Instance oradb2 is running on node node2

Now database is up and running on both DB nodes.


5. Start Oracle Home process accessing database: let's start listener and OEM to access database and allow users to connect to the database.

[grid@node1 bin]$ srvctl start listener -n node1

[grid@node1 bin]$ srvctl status listener -n node1
Listener LISTENER is enabled on node(s): node1
Listener LISTENER is running on node(s): node1

[oracle@database ~]$ emctl start dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.2.0.2.0 
Copyright (c) 1996, 2010 Oracle Corporation.  All rights reserved.
https://database.example.com:5500/em/console/aboutApplication
Starting Oracle Enterprise Manager 11g Database Control ..........................
. started. 
------------------------------------------------------------------
Logs are generated in directory /etc/oracle/oracle/database.example.com_orcl/sysman/log 

Now Database is ready to user. Since, shutting down and starting up RAC database is a series of steps. SO, I tried to make a one place repository for Shutdown and Start Oracle Real Application Clusters Database. If you wants to Shutdown or Restart Oracle RAC database Server.

Tuesday, May 28, 2019

CRS-0184 Cannot Communicate With The CRS Daemon in Oracle

CRS-0184 Cannot Communicate With The CRS Daemon in Oracle

I got an error like CRS-0184 on Oracle 11g RAC system, because of interconnect network is down. After network was up, CRS Daemon did not start. You can take these errors like CRS-0184, CRS-2674, CRS-4534, CRS-4530.. I resolved that problem with below operations.

CRS Stop and Start
[root@node2 ~] cd $GRID_HOME/bin
[root@node2 bin] ./crsctl stop cluster -all
[root@node2 bin] ./crsctl start cluster -all
Check CRS
[root@node2 bin] ./crsctl check crs
[root@node2 bin] ./crsctl check cluster -all
Note : All services have to be up.
Run root.sh
Note : If Cluster Virtual IPS not received, You can run root.sh
[root@node2 ~] cd $GRID_HOME
[root@node2 ~] ./root.sh
[root@node2 ~] cd $ORACLE_HOME
[root@node2 ~] ./root.sh

Various CRS Control Commands
crs_stat -t
crsctl stop has
crsctl start has
crsctl start resource
crsctl stop resource
crsctl status server

Wednesday, May 22, 2019

Top 50 Sql Server Dba Interview Questions And Answers Pdf

Top 50 Sql Server Dba Interview Questions And Answers Pdf


Are you looking for SQL Server Dba Interview Questions for Fresher’s or experienced? You are at accurate place. There are loads of chances from various reputed corporations in the business. According to analysis, SQL Server Dba has a business share of around 1.6%. So, you, however, have a chance to move forward in your career in SQL Server Dba Development. To achieve the desired job as SQL Server Dba Developer you need to go through the advanced topic in SQL Server Dba Interview Questions 2018 provided by SVR Technologies (SQL Online Training).

Top 50 Sql Server Dba Interview Questions And Answers Pdf

SQL Server programs on-demand IT Pros, and Developers and drive your experiences to a new level. By our selection of SQL Server Online Training occasions, you can see how to execute and control database explications, operate with great reporting innovations and recognize how SQL Server combines with SharePoint. SVR Technologies give SQL Server training online at your registered time, you can choose classes where, when, and how it accommodates you the best.
Here is top 50 objective standard model SQL Server Dba Interview questions and their answers are provided just underneath to them(SQL Server Job Support Online). Some sample questions are included by masters from SVR Technologies who guides for What Is SQL Server Dba to deliver you a conception of the nature of questions which may be asked in an interview. We have taken complete care to provide accurate answers to all the questions.

1. What is BCP ? When does it used ? (Top 50 Sql Server Dba Interview Questions And Answers Pdf)
Answer :
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. BULK INSERT command helps to import a data file into a database table or view in a user-specified format.
Top 50 Sql Server Dba Interview Questions And Answers Pdf

2. When would you use it ?
Answer :
An execution plan is basically a road map that graphically or textually shows the data retrieval methods chosen by the SQL Server query optimizer for a stored procedure or ad- hoc query and is a very useful tool for a developer to understand the performance characteristics of a query or stored procedure since the plan is the one that SQL Server will place in its cache and use to execute the stored procedure or query. From within Query Analyzer is an option called “Show Execution Plan” (located on the Query drop-down menu). If this option is turned on it will display query execution plan in separate window when query is ran again.

3. How to implement one-to-one, one-to-many and many-to-many relationships while designing tables ?
Answer :
One-to-One relationship can be implemented as a single table and rarely as two tables with primary and foreign key relationships. One-to-Many relationships are implemented by splitting the data into two tables with primary key and foreign key relationships. Many-to-Many relationships are implemented using a junction table with the keys from both the tables forming the composite primary key of the junction table.
Top 50 Sql Server Dba Interview Questions And Answers Pdf

4. Explain primary key in Sql Server ?
Answer :
This is the combination of fields/columns which are used to uniquely specify a row. Primary Key has a unique constraint defined on the column and the value in the column cannot be NULL.

5. Explain foreign key in Sql Server ?
Answer :
Foreign key is used to establish a relationship between the columns of other table. Foreign key relationship to be created between two tables by referencing a column of the table to primary key of another table.

6. What are the difference between “Where” and “Having” clause in Sql Server ?
Answer :
“Where” clause is used to filter the rows based on condition. “Having” clause used with SELECT clause and this is used with GROUP BY clause. If GROUP BY clause not used then “HAVING” clause works like a “WHERE” clause. Top 50 Sql Server Dba Interview Questions And Answers Pdf

7. What is Magic Tables in SQL Server ?
Answer :
The MAGIC tables are automatically created and dropped, in case you use TRIGGERS. SQL Server has two magic tables named, INSERTED and DELETED
These are mantained by SQL server for there Internal processing. When we use update insert or delete on tables these magic tables are used.These are not physical tables but are Internal tables.When ever we use insert statement is fired the Inserted table is populated with newly inserted Row and when ever delete statement is fired the Deleted table is populated with the delete
d row.But in case of update statement is fired both Inserted and Deleted table used for records the Original row before updation get store in Deleted table and new row Updated get store in Inserted table.

8. List out the different types of locks available in Sql Server ?
Answer :
Below are the list of locks available in Sql Server –
Update Locks
Shared Locks
Exclusive Locks
Top 50 Sql Server Dba Interview Questions And Answers Pdf

9. What is recursive stored procedure in Sql Server ?
Answer :
Recursive stored procedure is the stored procedure called as child stored procedure inside the parent or main stored procedure. This can be done easily in Sql Server by using “EXEC” keyword in a stored procedure. For example
Create Procedure SP_Test
AS
BEGIN
EXEC sp_Child @params
END
Top 50 Sql Server Dba Interview Questions And Answers Pdf

10. How the authentication mode can be changed ?
Answer :
Authentication mode can be changed using following steps –
Start -> Programs -> Microsoft SQL Server -> “SQL Enterprise Manager” and run SQL Enterprise Manager.

11. What are the new features in SQL Server 2005 when compared to SQL Server 2000 ?
Answer :
There are quite a lot of changes and enhancements in SQL Server 2005. Few of them are listed here :
Database Partitioning
Dynamic Management Views
System Catalog Views
Resource Database
Database Snapshots
SQL Server Integration Services
Support for Analysis Services on a a Failover Cluster.
Profiler being able to trace the MDX queries of the Analysis Server.
Peer-to Peer Replication
Database Mirroring

12. How to get @@ERROR and @@ROWCOUNT at the same time ?
Answer :
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.

13. Explain Sql server authentication modes ?
Answer :
Below are the two authentication modes of sql server –
Mixed Mode
Windows Mode
Top 50 Sql Server Dba Interview Questions And Answers Pdf

14. What does man by SQL Wildcard Characters in Sql Serve ?
Answer :
WildCard Characters are used with “LIKE” operator in Sql Server. Wildcards are used for data retrieval process from the table. Some of the wildcards are
“-“ – This is used for substituting a single character.
“%” – This is used for substituting zero or more characters.
[list of chars] – Ranges of characters for matching.

15. Explain Indexing and what are the advantages of it ?
Answer :
Indexing contains pointers to the data in a table. Indexes are created in a table to retrieve the data quickly. So Indexing improves the performance as the retrieval of data takes less time. Indexing will be done for columns which are being used more often while retrieving.
Top 50 Sql Server Dba Interview Questions And Answers Pdf

16. Explain “NOT NULL Constraint” in Sql Server ?
Answer :
“NOT NULL Constraint” is used in a column to make sure the value in the column is not null. If this constraint has not set then by default columns will accept NULL values too.
Top 50 Sql Server Dba Interview Questions And Answers Pdf

17. Why to use Sub Query in Sql Server and List out types of Sub Queries ?
Answer :
Sub Queries are queries within a query. The parent or outer query is being called as main query and the inner query is called as inner query or sub query. Different types of Sub Queries are
Correlated – It is not an independent subquery. It is an inner query which is referred by outer query.
Non Correlated – It is an independent subquery. It can be executed even without outer query.

18. What are user defined functions (UDFs) in Sql Server ?
Answer :
User Defined functions are being used to handle complex queries.
There are two types of user defined functions –
Scalar – This type of functions are used for returning single scalar value.
Table Valued – This type of function are used for returning a table which has list of rows. Sql supports data type called table which is used here for returning a table.

19. List out difference between Union and Union All in Sql Server ?
Answer :
Union is used to combine all result sets and it removes the duplicate records from the final result set obtained unlike Union All which returns all the rows irrespective of whether rows are being duplicated or not.
Union checks the number of columns given in the SELECT statement should be equal or not and the datatypes are also should be same and same applied to UnionAll.

20.Explain “@@ROWCOUNT” and “@@ERROR” in Sql Server ?
Answer :
@@ROWCOUNT – Used to return the number of rows affected in the table due to last statement.
@@ERROR – Used to return the error code which is occurred due to last SQL statement. ‘0’ means there are no errors.

21. Why to use Cursor in Sql Server ?
Answer :
Cursor is used in case of row traversal. This can be considered as a pointer pointing to one row at a time in the list of rows. Cursors can be used for retrieval, removal or addition of records in a table.

22. List all types of constraints in Sql Server ?
Answer :
Below are the list of constraints in Sql Server –
NOT NULL
DEFAULT
CHECK
PRIMARY KEY
FOREIGN KEY
UNIQUE
Top 50 Sql Server Dba Interview Questions And Answers Pdf

23. Why to use IDENTITY in Sql Server ?
Answer :
IDENTITY is used for a column to auto increment the value of the column in a table and it is mainly used with Primary Key.

24. What are the differences between Union, Intersect and Minus operators ?
Answer :
Union operator is used to combine all the results or records of the table and it removes the duplicate values.
Interact operator is used to return the common list of records between two result sets.
Minus operator is used to get the list of records from the first result set and which is not there in second result set.

25. Explain “ROW_NUMBER()” in Sql Server with an example ?
Answer :
“ROW_NUMBER()” is used to return a sequential number of each row within a given partition. “1” will be the first position. “Partition By” and “Order By” can be used along with “ROW_NUMBER()”. Below is the example for the same
SELECT ROW_NUMBER() OVER(ORDER BY EmpSalary DESC) AS Row FROM Employees WHERE Emp Name Name IS NOT NULL
Top 50 Sql Server Dba Interview Questions And Answers Pdf

26. What are the differences between “ROW_NUMBER()”, “RANK()” and “DENSE_RANK()”?
Answer :
“ROW_NUMBER” – Used to return a sequential number of each row within a given partition.
“RANK” – Used to returns a new row number for each distinct row in the result set and it will leave a number gap in case of duplicates.
“DENSE_RANK” – Used to returns a new row number for each distinct row in the result set and it will not leave any number gap in case of duplicates.

27. Explain about Link Server in Sql Server ?
Answer :
Linked Server is used to enable execution of OLEDB data sources in remote servers. With Linked servers we can create easy SQL statements which will allow remote data to be joined, combined and retrieved with data in local.
(Top 50 Sql Server Interview Questions And Answers Pdf)

28. What are the advantages of user defined functions over stored procedures in Sql Server ?
Answer :
User Defined functions can be used in SELECT/WHERE/HAVING clauses whereas stored procedure cannot be called. In case of table valued functions, the returned table.

29. Why to use “NoLock” in Sql Server ?
Answer :
“No Lock” is used for unlocking the rows which are locked by some other transaction. Once after the rows are committed or rolled back no need to use No Lock. For example.
Top 50 Sql Server Dba Interview Questions And Answers Pdf

30. What are the significance of master, tempdb and model databases ?
Answer :
master – This database will have data and catalog of all the databases of SQL Server instance.
tempdb – tempdb database will have temporary objects like local and global temporary tables and stored procedures as well.
model – model database is mainly used for creating new user databases.

31. Explain about unique identifier datatype in Sql Server ?
Answer :
Unique Identifier datatype mainly used for primary key columns of the tables or any other columns which need to have unique Ids. “NEWID()” function can be used for generating unique identifier for the column. Unique Identifiers are also named as GUIDs.

32. Why to use “PIVOT” in Sql Server ?
Answer :
Pivot table automatically count, sort and total the data in a table or spreadsheet and used to create a separate table for displaying summarized data.

33. Explain Alternate key, Candidate Key and Composite Key in Sql Server ?
Answer :
Alternate Key – To identity a row uniquely we can have multiple keys one of them is called primary key and rest of them are called alternate keys.
Candidate Key – Set of fields or columns which are uniquely identified in a row and they constitute candidate keys.
Composite Key – One key formed by combining at least two or more columns or fields.

34. How to use “DROP” keyword in Sql Server and Give an example ?
Answer :
“DROP” keyword is used to drop either Index or database or table. Below are list of Sql statements using Drop keyword.
Dropping Index
DROP INDEX my_index
Dropping Database
DROP DATABASE my_database
Dropping Table
DROP TABLE my_table
deleted when the connection that created it is closed.

35. Can SQL servers link to other servers?
Answer:
SQL server can be joined to any database which owns OLE-DB provider to provide a link. Example: Oracle holds OLE-DB provider which has a link to unite among the SQL server club.

36. What is subquery and its properties ?
Answer :
A subquery is a query which can be nested inside a main query like Select, Update, Insert or Delete statements. This can be used when expression is allowed. Properties of subquery can be defined as
A sub query should not have order by clause
A subquery should be placed in the right hand side of the comparison operator of the main query
A subquery should be enclosed in parenthesis because it needs to be executed first before the main query
More than one subquery can be included.
Top 50 Sql Server Dba Interview Questions And Answers Pdf

37. What are the kinds of subquery?
Answer :
There are 3 kinds of subquery –
The query which returns only one row is Single row subquery
Which returns multiple rows is multiple row subquery
Which returns multiple columns to the main query is multiple column subqueries. Beside that subquery returns, the Chief query will be performed.

38. What is SQL server agent ?
Answer :
The SQL Server agent performs an active role in day to day duties of SQL server manager (DBA). Server agent’s goal is to achieve the jobs simply with the scheduler motor which provides our jobs to work at proposed date and time.

39. What are scheduled tasks in SQL Server ?
Answer: Scheduled jobs are practiced to automate methods that can be operated on a cataloged event at a constant interval. This scheduling of jobs benefits to decrease human interference throughout night time and feed can be produced at an appropriate time. A user can further order the jobs in which it allows to be produced.

40. What is COALESCE in SQL Server ?
Answer :
COALESCE is used to return first non-null expression within the arguments. This function is used to return a non-null from more than one column in the arguments.

41. If you are given access to a SQL Server, how do you find if the SQL Instance is a named instance or a default instance ?
Answer :
I would go to the SQL Server Configuration Manager. In the left pane of the tool, I would select SQL Server Services, the right side pane displays all of the SQL Server Services / components that are installed on that machine. If the Service is displayed as (MSSQLSERVER), then it indicates it is a default instance, else there will be the Instance name displayed.

42. What structure can you implement for the database to speed up table reads ?
Answer :
A) Follow the rules of DB tuning we have to:
1] properly use indexes ( different types of indexes)
2] properly locate different DB objects across different tablespaces, files and so on.
3] create a special space (tablespace) to locate some of the data with special datatype ( for example CLOB,

43. What are statistics, under what circumstances they go out of date, how do you update them ?
Answer :
A) Statistics determine the selectivity of the indexes. If an indexed column has unique values then the selectivity of that index is more, as opposed to an index with non-unique values. Query optimizer uses these indexes in determining whether to choose an index or not while executing a query.
Some situations under which you should update statistics:
If there is significant change in the key values in the index
If a large amount of data in an indexed column has been added, changed, or removed (that is, if the distribution of key values has changed), or the table has been truncated using the TRUNCATE TABLE statement and then repopulated
Database is upgraded from a previous version Q) Could you please some items which you may see in an execution plan indicating the query is not optimized.
Index Scan or Table ScanHash Joins
Thick arrows (indicating large work tables)
Parallel streams (Parallelism)
Bookmark lookup (or key lookup)
Top 50 Sql Server Dba Interview Questions And Answers Pdf

44. In what sequence SQL statement are processed ?
Answer :
The clauses of the select are processed in the following sequence
FROM clause
WHERE clause
GROUP BY clause
HAVING clause
SELECT clause
ORDER BY clause
TOP clause

45. Can we add identity column to decimal datatype ?
Answer :
YES, SQL Server support this
What is the Difference between LEFT JOIN with WHERE clause & LEFT JOIN with no WHERE clause ?
OUTER LEFT/RIGHT JOIN with WHERE clause can act like an INNER JOIN if not used wisely or logically.

46. What is meant by Active – Passive and Active – Active clustering setup ?
Answer:
An Active – Passive cluster is a failover cluster configured in a way that only one cluster node is active at any given time. The other node, called as Passive node is always online but in an idle condition, waiting for a failure of the Active Node, upon which the Passive Node takes over the SQL Server Services and this becomes the Active Node, the previous Active Node now being a Passive Node.
An Active – Active cluster is a failover cluster configured in a way that both the cluster nodes are active at any given point of time. That is, one Instance of SQL Server is running on each of the nodes always; when one of the nodes has a failure, both the Instances run on the only one node until the failed node is brought up (after fixing the issue that caused the node failure). The instance is then failed over back to its designated node.

47. How do you generate file output from SQL ?
Answer:
While using SQL Server Management Studio or Query Analyzer, we have an option in Menu BAR. QUERTY >> RESULT TO >> Result to FILE
How do you prevent SQL Server from giving you informational messages during and after a SQL statement execution?
SET NOCOUNT OFF

48. What is the importance of a recovery model ?
Answer :
Primarily, recovery model is chosen keeping in view the amount of data loss one can afford to. If one expects to have minimal or no data loss, choosing the Full recovery model is a good choice. Depending on the recovery model of a database, the behavior of database log file changes. I would recommend you read more material on log backups and log file behavior and so on to understand in depth.

49. What is Index, cluster index and non cluster index ?
Answer :
Clustered Index:- A Clustered index is a special type of index that reorders the way records in the table are physically stored. Therefore table may have only one clustered index.Non-Clustered Index:- A Non-Clustered index is a special type of index in which the logical order of the index does not match the physical stored order of the rows in the disk. The leaf nodes of a non-clustered index does not consists of the data pages. instead the leaf node contains index rows.
Write down the general syntax for a SELECT statements covering all the options.
Here’s the basic syntax: (Also checkout SELECT in books online for advanced syntax).

50. What are the different Authentication modes in SQL Server and how can you change authentication mode ?
Answer :
SQL Server has 2 Authentication modes; Windows Authentication and SQL Server and Windows Authentication mode also referred as Mixed Mode. To change the Authentication mode, read one of my blogs Changing SQL Server Authentication Mode.

SQL Server DBA Interview Questions

SQL Server DBA Interview Questions

If you're looking for SQL Server DBA Interview Questions for Experienced or Freshers, you are at right place. There are a lot of opportunities from many reputed companies in the world. According to research SQL Server, DBA has a market share of about 46%. So, You still have the opportunity to move ahead in your career in SQL Server DBA... Mindmajix offers Advanced SQL Server DBA. Interview Questions 2019 that helps you in cracking your interview & acquire dream career as SQL Server DBA Developer.
SQL Server DBA Course is meticulously designed for beginners and professionals who wanted to start/empower their skillset on SQL Server Database Administration.

Q1) MS SQL Server Vs MySQL

MS SQL Server Vs MySQL
NameMS SQL ServerMySQL
DefineMicrosoft Relational Data Base Management SystemWide usage of Relational Data Base Management system
Primary DB ModelRelational DB Management SystemRelational DB Management System
Secondary DB ModelGraph DBMS, Document & Value storeDocument & Key-Value store
DeveloperIt is developed by MicrosoftIt is developed by Oracle
Server OSIt supports Windows, LinuxIt supports Linux, Solaris, Windows, OS X
Supporting LanguagesJava, PHP, Ruby, C#, C++, R etcPython, TCL, Scheme, Haskell, Javascript, Ruby, C, C++, C# few more 
FK(Foreign Key)Yes they supportYes they support
API'sJDBC, ODBC, OLE DB, TDSODBC, ADO.NET, JDBC
License PermitOnly CommercialOpenSource (Free)

Q2) What purpose does the model database serve?
The model database, as its name implies, serves as the model (or template) for all databases created on the same instance. If the model database is modified, all subsequent databases created on that instance will pick up those changes, but earlier created databases will not. Note that TEMPDB is also created from model every time SQL Server starts up.

Q3) How do you trace the traffic hitting a SQL Server?
SQL profiler is the SQL Server utility you can use to trace the traffic on the SQL Server instance. Traces can be filtered to narrow down the transactions that are captured and reducing the overhead incurred for the trace. The trace files can be searched, saved off, and even replayed to facilitate troubleshooting.

Q4) What types of replication are supported in SQL Server?
SQL Server has three types of replication: Snapshot, Merge, and Transaction. Snapshot replication creates a snapshot of the data (point-in-time picture of the data) to deliver to the subscribers. This is a good type to use when the data changes infrequently, there is a small amount of data to replicate, or large changes occur over a small period of time.
Merge replication uses a snapshot to seed the replication. Changes on both sides of the publication are tracked so the subscriber can synchronize with the publisher when connected. A typical use for this type of replication is in a client and server scenario. A server would act as a central repository and multiple clients would independently update their copies of the data until connected. At which time, they would all send up their modifications to the central store.
Transaction replication also begins with a snapshot only this time changes are tracked as transactions (as the name implies). Changes are replicated from publisher to subscriber the same as they occurred on the publisher, in the same order as they occurred, and in near real time. This type of replication is useful when the subscriber needs to know every change that occurred to the data (not point-in-time), when the change volume is high, and when the subscriber needs near real-time access to the changes.
<span style="font-size:14px;"><span style="font-family:times new roman,times,serif;"><strong>You can visit here to <a href="https://mindmajix.com/sql-server-training" target="_blank"><span style="color:#FF0000;">Learn SQL Server Course</span></a></strong></span></span>

Q5) Why would you use SQL Agent?
SQL Agent is the job scheduling mechanism in SQL Server. Jobs can be scheduled to run at a set time or when a specific event occurs. Jobs can also be executed on demand. SQL Agent is most often used to schedule administrative jobs such as backups.

Q6) What happens on checkpoint?
Checkpoints, whether scheduled or manually executed, cause the transaction log to be truncated up to the beginning of the oldest open transaction (the active portion of the log). That is, the dirty pages from the buffer cache are written to disk. Storing committed transactions in the cache provides a performance gain for SQL Server. However, you do not want the transaction log to get too big because it might consume too many resources and, should your database fail, take too long to process to recover the database.
One important thing to note here is that SQL Server can only truncate up to the oldest open transaction. Therefore, if you are not seeing the expected relief from a checkpoint, it could very well be that someone forgot to commit or rollback their transaction. It is very important to finalize all transactions as soon as possible.

Q7) What is DBCC?
DBCC statements are Database Console Commands and come in four flavors: Maintenance, Informational, Validation, and Miscellaneous. Maintenance commands are those commands that allow the DBA to perform maintenance activities on the database such as shrinking a file. Informational commands provide feedback regarding the database such as providing information about the procedure cache. Validation commands include commands that validate the database such as the ever-popular CHECKDB. Finally, miscellaneous commands are those that obviously don’t fit in the other three categories. This includes statements like DBCC HELP, which provides the syntax for a given DBCC command.

Q8) How can you control the amount of free space in your index pages?
You can set the fill factor on your indexes. This tells SQL Server how much free space to leave in the index pages when re-indexing. The performance benefit here is fewer page splits (where SQL Server has to copy rows from one index page to another to make room for an inserted row) because there is room for growth built into the index.

Q9) Why would you call Update Statistics?
Update Statistics is used to force a recalculation of query optimization statistics for a table or indexed view. Query optimization statistics are automatically recomputed, but in some cases, a query may benefit from updating those statistics more frequently. Beware though that re-computing the query statistics causes queries to be recompiled. This may or may not negate all performance gains you might have achieved by calling update statistics. In fact, it could have a negative impact on performance depending on the characteristics of the system.

Q10) What is a correlated sub-query?
A correlated sub-query is a nested query that is linked to the outer query. For instance, say I wanted to find all the employees who have not entered their time for the week. I could query the Employee table to get their first and last name, but I need to look at the TimeEntry table to see if they’ve entered their time or not. I can’t do a straight join here because I’m looking for the absence of time data, so I’ll do a correlated sub-query similar to this:
SELECT FirstName, LastName
FROM EMPLOYEE e
WHERE NOT EXISTS (SELECT 1 FROM TimeEntry te
WHERE te.EmpID = e.EmpID
AND te.WeekID = 35)
Notice that the inner query relates to the outer query on the employee ID, thus making it a correlated sub-query. The inner query will be evaluated once per outer query row.

Q11) What authentication modes does SQL Server support?
SQL Server supports Windows Authentication and mixed-mode. Mixed-mode allows you to use both Windows Authentication and SQL Server Authentication to log into your SQL Server. It’s important to note that if you use Windows Authentication, you will not be able to log in as sa.

Q12) Explain about your SQL Server DBA Experience.
This is a generic question often asked by many interviewers. Explain what are the different SQL Server Versions you have worked on, what kind of administration of those instances has been done by you. Your role and responsibilities carried out in your earlier projects that would be of significance to the potential employer. This is the answer that lets the interviewer know how suitable are you for the position to which you are being interviewed.

Q13) What are the different SQL Server Versions you have worked on?
The answer would be depending on the versions you have worked on, I would say I have experience working in SQL Server 7, SQL Server 2000, 2005 and 2008. If you have worked only some version be honest in saying that, remember, no one would be working on all versions, it varies from individual to individual.

Q14) What are the different types of Indexes available in SQL Server?
The simplest answer to this is “Clustered and Non-Clustered Indexes”. There are other types of Indexes what can be mentioned such as Unique, XML, Spatial and Filtered Indexes. More on these Indexes later.

Q15) What is the difference between Clustered and Non-Clustered Index?
In a clustered index, the leaf level pages are the actual data pages of the table. When a clustered index is created on a table, the data pages are arranged accordingly based on the clustered index key. There can only be one Clustered index on a table.

In a Non-Clustered index, the leaf level pages do not contain data pages instead it contains pointers to the data pages. There can multiple non-clustered indexes on a single table.

Q16) What are the new features in SQL Server 2005 when compared to SQL Server 2000?
There are quite a lot of changes and enhancements in SQL Server 2005. Few of them are listed here:
  • Database Partitioning
  • Dynamic Management Views
  • System Catalog Views
  • Resource Database
  • Database Snapshots
  • SQL Server Integration Services
Support for Analysis Services on a Failover Cluster.
1.Profiler being able to trace the MDX queries of the Analysis Server.
2.Peer-toPeer Replication
3.Database Mirroring

Q17) What are the High-Availability solutions in SQL Server and differentiate them briefly.
Failover Clustering, Database Mirroring, Log Shipping, and Replication are the High-Availability features available in SQL Server. I would recommend reading this blog of mine which explains the differences between these 4 features.

Q18) How do you troubleshoot errors in a SQL Server Agent Job?
Inside SSMS, in Object Explorer under SQL Server Agent look for Job Activity Monitor. The job activity monitor displays the current status of all the jobs on the instance. Choose the particular job which failed, right click and choose view history from the drop-down menu. The execution history of the job is displayed and you may choose the execution time (if the job failed multiple times during the same day). There would information such as the time it took to execute that Job and details about the error occurred.

Q19) What is the default Port No on which SQL Server listens?
1433




Q20) How many files can a Database contain in SQL Server? How many types of data files exist in SQL Server? How many of those files can exist for a single database?
1. A Database can contain a maximum of 32,767 files.
2. There are Primarily 2 types of data files Primary data file and Secondary data file(s)
3. There can be only one Primary data file and multiple secondary data files as long as thetotal # of files is less than 32,767 files

Q21) What is DCL?
DCL stands for Data Control Language.

Q22) What are the commands used in DCL?
GRANT, DENY and REVOKE.

Q23) What is Fill Factor?
Fill Factor is a setting that is applicable to Indexes in SQL Server. The fill factor value determines how much data is written to an index page when it is created/rebuilt.

Q24) What is the default fill factor value?
By default, the fill factor value is set to 0.

Q25) Where do you find the default Index fill factor and how to change it?
The easiest way to find and change the default fill factor value is from Management Studio, right-click the SQL Server and choose properties. In the Server Properties, choose Database Settings, you should see the default fill factor value in the top section. You can change to the desired value there and click OK to save the changes.
The other option of viewing and changing this value is using

Q26) What is a system database and what is a user database?
System databases are the default databases that are installed when the SQL Server is installed. Basically, there are 4 system databases: Master, MSDB, TempDB, and Model. It is highly recommended that these databases are not modified or altered for the smooth functioning of the SQL System.
A user database is a database that we create to store data and start working with the data.

Q27) What are the recovery models for a database?
There are 3 recovery models available for a database. Full, Bulk-Logged and Simple are the three recovery models available.

Q28) What is the importance of a recovery model?
Primarily, the recovery model is chosen keeping in view the amount of data loss one can afford to. If one expects to have minimal or no data loss, choosing the Full recovery model is a good choice. Depending on the recovery model of a database, the behavior of database log file changes. I would recommend you read more material on log backups and log file behavior and so on to understand in depth.

Q29) What is Replication?
Replication is a feature in SQL Server that helps us publish database objects and data and copy (replicate) it to one or more destinations. It is often considered as one of the High-Availability options. One of the advantages of Replication is that it can be configured on databases which are in simple recovery model.

Q30) What the different types of Replication and why are they used?
There are basically 3 types of replication: Snapshot, Transactional and Merge Replication. The type of Replication you choose depends on the requirements and/or the goals one is trying to achieve.For example, Snapshot Replication is useful only when the data inside the tables does not change frequently and the amount of data is not too large, such as a monthly summary table or a product list table etc. Transactional Replication would useful when maintaining a copy of a transactional table such as sales order tables etc. Merge Replication is more useful in case of remote / distributed systems where the data flow can be from multiple sites, for example, sales done at a promotional event which might not be connected to the central servers always.

Q31) What the different components of Replication and what is their use?
The 3 main components in Replication are Publisher, Distributor, and Subscriber. The publisher is the data source of a publication. The distributor is responsible for distributing the database objects to one or more destinations. The subscriber is the destination where the publisher's data is copied/replicated.

Q32) What are the different Topologies in which Replication can be configured?
Replication can be configured in any topology depending keeping in view of the complexity and the workload of the entire Replication. It can be any of the following:
  • Publisher, Distributor, and Subscriber on the same SQL Instance.
  • Publisher and Distributor on the same SQL Instance and Subscriber on a separate Instance.
  • Publisher, Distributor, and Subscriber on individual SQL Instances.
Q33) If you are given access to a SQL Server, how do you find if the SQL Instance is a named instance or a default instance?
I would go to the SQL Server Configuration Manager. In the left pane of the tool, I would select SQL Server Services, the right side pane displays all of the SQL Server Services/components that are installed on that machine. If the Service is displayed as (MSSQLSERVER), then it indicates it is a default instance, else there will be the Instance name displayed.

Q34) What are the different Authentication modes in SQL Server and how can you change authentication mode?
SQL Server has 2 Authentication modes; Windows Authentication and SQL Server and Windows Authentication mode also referred to as Mixed Mode.

Q35) What are the differences in Clustering in SQL Server 2005 and 2008 or 2008 R2?
On SQL Server 2005, installing SQL Server failover cluster is a single step process whereas on SQL Server 2008 or above it is a multi-step process. That is, in SQL Server 2005, the Installation process itself installs on all of the nodes (be it 2 nodes or 3 nodes). In 2008 or above this has changed, we would need to install separately on all the nodes. 2 times if it is a 2 node cluster or 3 times in a 3 node cluster and so on.

Q36) What is meant by Active-Passive and Active-Active clustering setup?
An Active-Passive cluster is a failover cluster configured in a way that only one cluster node is active at any given time. The other node, called as the Passive node is always online but in an idle condition, waiting for a failure of the Active Node, upon which the Passive Node takes over the SQL Server Services and this becomes the Active Node, the previous Active Node now being a Passive Node.
An Active-Active cluster is a failover cluster configured in a way that both the cluster nodes are active at any given point in time. That is, one Instance of SQL Server is running on each of the nodes always; when one of the nodes has a failure, both the Instances run on the only one node until the failed node is brought up (after fixing the issue that caused the node failure). The instance is then failed over back to its designated node.

Q37) List out some of the requirements to setup a SQL Server failover cluster.
Virtual network name for the SQL Server, Virtual IP address for SQL Server, IP addresses for the Public Network and Private Network(also referred as Heartbeat) for each node in the failover cluster, shared drives for SQL Server Data and Log files, Quorum Disk, and MSDTC Disk.

Q38) What is Transparent Data Encryption?
Introduced in SQL Server 2008 Transparent Data Encryption (TDE) is a mechanism through which you can protect the SQL Server Database files from unauthorized access through encryption. Also, TDE can protect the database backups of the instance on which TDE was setup.

Q39) Does Transparent Data Encryption provide encryption when transmitting data across the network?
No, Transparent Data Encryption (TDE) does not encrypt the data during transfer over a communication channel.

Q40) What are the operating modes in which Database Mirroring runs?
Database Mirroring runs in 2 operating modes High-Safety Mode and High-Performance Mode.

Q41) What is the difference between the 2 operating modes of Database Mirroring (mentioned in the above answer)?
1. High-Safety Mode is to ensure that the Principal and Mirrored database are synchronized state, that is the transactions are committed at the same time on both servers to ensure consistency, but there is/might be a time lag.
2. High-Performance Mode is to ensure that the Principal database run faster, by not waiting for the Mirrored database to commit the transactions. There is a slight chance of data loss and also the Mirrored database can be lagging behind (in terms being up to date with the Principal database) if there is a heavy load on the Mirrored Server.

Q42) When setting Replication, is it possible to have a Publisher as 64 Bit SQL Server and Distributor or Subscribers as a 32 Bit SQL Server.
Yes, it is possible to have various configurations in a Replication environment.

Q43) What is the difference between dropping a database and taking a database offline?
Drop database deletes the database along with the physical files, it is not possible to bring back the database unless you have a backup of the database. When you take a database offline, you the database is not available for users, it is not deleted physically, it can be brought back online.

Q44) Which autogrowth database setting is good?
Setting an autogrowth in multiples of MB is a better option than setting autogrowth in percentage (%).

Q45) What are the different types of database compression introduced in SQL Server 2008?
Row compression and Page Compressionn.

Q46) What are the different types of Upgrades that can be performed in SQL Server?
In-place upgrade and Side-by-Side Upgrade.
Explore SQL Server DBA Sample Resumes! Download & Edit, Get Noticed by Top Employers!Download Now!

Q47) On a Windows Server 2003 Active – Passive failover cluster, how do you find the node which is active?
Using Cluster Administrator, connect to the cluster and select the SQL Server cluster.  Once you have selected the SQL Server group, on the right-hand side of the console, the column“Owner” gives us the information of the node on which the SQL Server group is currently active.

Q48) How do you open a Cluster Administrator?
From Start -> Run and type CluAdmin (case insensitive) and the Cluster Administrator console is displayed OR you can also go to Start -> All Programs -> Administrative Tools -> Cluster Administrator.

Q49) Due to some maintenance being done, the SQL Server on a failover cluster needs to be brought down. How do you bring the SQL Server down?
In the Cluster Administrator, rick click on the SQL Server Group and from the popup menu item choose to Take Offline.

Q50) What are the different ways you can create Databases in SQL Server?
  • 1.T-SQL; Create Database command.
  • 2.Using Management Studio
  • 3.Restoring a database backup
  • 4.Copy Database wizard
Q51) When setting Replication, can you have Distributor on SQL Server 2005, Publisher of SQL Server 2008?
No, you cannot have a Distributor on a previous version than the Publisher.

List of Related Microsoft Certification Courses:


SQL Server DBA Interview Questions and answers

SQL Server DBA Interview Questions and answers



Question.1  Which TCP/IP port does SQL Server run on? How can it be changed?
Answer:  SQL Server runs on port 1433. It can be changed from the Network Utility TCP/IP properties.

Question.2   What are the difference between clustered and a non-clustered index?
Answer:  A clustered index is a special type of index that reorders the way records in the table are physically stored. Therefore table can have only one clustered index. The leaf nodes of a clustered index contain the data pages. A non clustered index is a special type of index in which the logical order of the index does not match the physical stored order of the rows on disk. The leaf node of a non clustered index does not consist of the data pages. Instead, the leaf nodes contain index rows.

Question.3   What are the different index configurations a table can have?
Answer:  A table can have one of the following index configurations:
No indexes
A clustered index
A clustered index and many nonclustered indexes
A nonclustered index
Many nonclustered indexes

Question.4  What are different types of Collation Sensitivity?
Answer:
Case sensitivity – A and a, B and b, etc.
Accent sensitivity
Kana Sensitivity – When Japanese kana characters Hiragana and Katakana are treated differently, it is called Kana sensitive.
Width sensitivity – A single-byte character (half-width) and the same character represented as a double-byte character (full-width) are treated differently than it is width sensitive.

Question.5   What is OLTP (Online Transaction Processing)?
Answer:   In OLTP – online transaction processing systems relational database design use the discipline of data modeling and generally follow the Codd rules of data normalization in order to ensure absolute data integrity. Using these rules complex information is broken down into its most simple structures (a table) where all of the individual atomic level elements relate to each other and satisfy the normalization rules.

Question.6   What’s the difference between a primary key and a unique key?
Answer:  Both primary key and unique key enforces uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a nonclustered index by default. Another major difference is that, primary key doesn’t allow NULLs, but unique key allows one NULL only.

Question.7   What is difference between DELETE and TRUNCATE commands?
Answer:  Delete command removes the rows from a table based on the condition that we provide with a WHERE clause. Truncate will actually remove all the rows from a table and there will be no data in the table after we run the truncate command.
TRUNCATE:
TRUNCATE is faster and uses fewer system and transaction log resources than DELETE.
TRUNCATE removes the data by deallocating the data pages used to store the table’s data, and only the page deallocations are recorded in the transaction log.
TRUNCATE removes all rows from a table, but the table structure, its columns, constraints, indexes and so on, remains. The counter used by an identity for new rows is reset to the seed for the column.
You cannot use TRUNCATE TABLE on a table referenced by a FOREIGN KEY constraint. Because TRUNCATE TABLE is not logged, it cannot activate a trigger.
TRUNCATE cannot be rolled back.
TRUNCATE is DDL Command.
TRUNCATE Resets identity of the table
DELETE:
DELETE removes rows one at a time and records an entry in the transaction log for each deleted row.
If you want to retain the identity counter, use DELETE instead. If you want to remove table definition and its data, use the DROP TABLE statement.
DELETE Can be used with or without a WHERE clause
DELETE Activates Triggers.
DELETE can be rolled back.
DELETE is DML Command.
DELETE does not reset identity of the table.
Note: DELETE and TRUNCATE both can be rolled back when surrounded by TRANSACTION if the current session is not closed. If TRUNCATE is written in Query Editor surrounded by TRANSACTION and if session is closed, it can not be rolled back but DELETE can be rolled back.

Question.8   When is the use of UPDATE_STATISTICS command?
Answer:   This command is basically used when a large processing of data has occurred. If a large amount of deletions any modification or Bulk Copy into the tables has occurred, it has to update the indexes to take these changes into account. UPDATE_STATISTICS updates the indexes on these tables accordingly.

Question.9   What is the difference between a HAVING CLAUSE and a WHERE CLAUSE?
Answer:   They specify a search condition for a group or an aggregate. But the difference is that HAVING can be used only with the SELECT statement. HAVING is typically used in a GROUP BY clause. When GROUP BY is not used, HAVING behaves like a WHERE clause. Having Clause is basically used only with the GROUP BY function in a query whereas WHERE Clause is applied to each row before they are part of the GROUP BY function in a query.

Question.10   What are the properties and different Types of Sub-Queries?
Answer:
Properties of Sub-Query
A sub-query must be enclosed in the parenthesis.
A sub-query must be put in the right hand of the comparison operator, and
A sub-query cannot contain an ORDER-BY clause.
A query can contain more than one sub-query.
Types of Sub-Query
Single-row sub-query, where the sub-query returns only one row.
Multiple-row sub-query, where the sub-query returns multiple rows,. and
Multiple column sub-query, where the sub-query returns multiple columns

Question.11   What is SQL Profiler?
Answer:  SQL Profiler is a graphical tool that allows system administrators to monitor events in an instance of Microsoft SQL Server. You can capture and save data about each event to a file or SQL Server table to analyze later. For example, you can monitor a production environment to see which stored procedures are hampering performances by executing too slowly.
Use SQL Profiler to monitor only the events in which you are interested. If traces are becoming too large, you can filter them based on the information you want, so that only a subset of the event data is collected. Monitoring too many events adds overhead to the server and the monitoring process and can cause the trace file or trace table to grow very large, especially when the monitoring process takes place over a long period of time.

Question.12  What are the authentication modes in SQL Server? How can it be changed?
Answer:  Windows mode and Mixed Mode – SQL and Windows. To change authentication mode in SQL Server click Start, Programs, Microsoft SQL Server and click SQL Enterprise Manager to run SQL Enterprise Manager from the Microsoft SQL Server program group. Select the server then from the Tools menu select SQL Server Configuration Properties, and choose the Security page.

Question.13   Which command using Query Analyzer will give you the version of SQL server and operating system?
Answer: SELECT SERVERPROPERTY (‘productversion’), SERVERPROPERTY (‘productlevel’), SERVERPROPERTY (‘edition’).

Question.14    What is SQL Server Agent?
Answer:  SQL Server agent plays an important role in the day-to-day tasks of a database administrator (DBA). It is often overlooked as one of the main tools for SQL Server management. Its purpose is to ease the implementation of tasks for the DBA, with its full- function scheduling engine, which allows you to schedule your own jobs and scripts.

Question.15   Can a stored procedure call itself or recursive stored procedure? How much level SP nesting is possible?
Answer:  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.

Question.16   What is Log Shipping?
Answer:  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 and can be used this as the Disaster Recovery plan. The key feature of log shipping is that it will automatically backup transaction logs throughout the day and automatically restore them on the standby server at defined interval.

Question.17  Name 3 ways to get an accurate count of the number of records in a table?
Answer:
SELECT * FROM table1
SELECT COUNT(*) FROM table1
SELECT rows FROM sysindexes WHERE id = OBJECT_ID(table1) AND indid < 2

Question.18    What does it mean to have QUOTED_IDENTIFIER ON? What are the implications of having it OFF?
Answer:  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.

Question.19   What is the difference between a Local and a Global temporary table?
Answer:  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.

  How to Change Instance Type & Security Group of EC2 in AWS By David Taylor Updated April 29, 2023 EC2 stands for Elastic Compute Cloud...