Wednesday, May 15, 2013

SQL DBA interview questions+ Wipro

Wipro 5+:

1. What is the performance counters used to check memory utilization.
2. Which DMV's we can use to check perform counters?
3. Which DMFs can we use to check the complete command running in a session.
4. Which exe file can be used to trace the server actitivites.
5. Statistics - How to update on a particular table index.
6. Memory configuration.
        If there is 16GB RAM, how can we make the server to use min 12 and          max 14.
        Lock pages in memory
7. How to improve the performance of Log Shipping.
8. How to move system dbs
        * TempDb
        * master
9. Execution plans
10.Why use DAC? How to connect?
11.Regular issues?
 

 

Best practices for installing service packs, cumulative updates and hotfixes for SQL Server
 
 
Test on a test/dev SQL Server first and only after you have confirmed that all applications are working as expected then install it on a production SQL Server. 
Review the Readme for Service Pack/cumulative update/hotfix. Any concerns/recommendations will be found in the readme. 
Run DBCC CHECKDB on ALL databases (user and system databases) and ensure that there were no errors reported. 
Backup ALL databases (user and system databases) and full-text catalogs (if applicable). This is NOT required but highly recommended. 
Stop Monitoring and Anti-virus services 
Make sure you have the proper permissions to install (administrative privilege on server/cluster node) 
The below points are for clustered SQL Server instance 
Make sure ALL SQL resources come online on ALL cluster nodes 
Make sure that ALL disk resources (even the ones that not being used by SQL Server) are online and not in failed state. 
Verify that there are no dependencies other than those created by the SQL Server setup on any SQL Server cluster resources. 
Run MPSRPT_SQL.exe on all cluster nodes (not required but recommended) 
Make sure all remote desktop connections are closed. You can connect to the node (you are running the setup from) 
using remote desktop connections but you should disconnect any remote connections to other cluster nodes.

SQL Server Interview Questions + CTS

1.     What are the differences between SQL 2005 and 2008?

2.     How to find which files are there in backup, without restoring?

3.     How to find locks?

4.     How to find log file size?

5.     How to check fragmentation?

6.     What are problems that you face in your carrier, Can you explain some situations?

7.     How to connect your sql server machine?

8.     What are the services that your company provides?

9.     What is your data base backup strategy?

10.  Difference between truncate and shrink?

Truncate: It truncates commited trns from logfile and not reduce file size, In the case of Shrink it reduce file size

11.  Is it possible to take backup of TempDB? No

12.  How many Clustered nodes are supported for sqlserver 2008R2, In Enterprise Edition?

Up to 16 nodes — Enter prise edition. (Windows 2008 server), in 2003 server 8 nodes

Up to 2 nodes — Enter prise edition.

SQL DBA interview questions+ HCL

1.     What is SQL Server Architecture?

2.     What is page?

3.     What is extent?

4.     What are the different types of extents?

Ans: Uniform extents: consists pages from same object, mixed mode extents: consists from different objects

5.     What is the difference between those two extents?

6.     Which pages are available in extents?

7.     What is fill factor?

8.     How to take backup of  DB when the db is in Log shipping by taking that backup without changing LSN?

Ans: By taking copy only backups

9.     How to change port number for sql server?

Ans: To assign a TCP/IP port number to the SQL Server Database Engine
In SQL Server Configuration Manager, in the console pane, expand SQL Server 2005 Network Configuration, expand Protocols for, and then double-click TCP/IP.
In the TCP/IP Properties dialog box, on the IP Addresses tab, several IP addresses appear, in the format IP1, IP2, up to IPAll. One of these are for the IP address of the loopback adapter, 127.0.0.1. Additional IP addresses appear for each IP Address on the computer. Right-click each address, and then click Properties to identify the IP address that you wish to configure.

10.  Is it possible to change port for mirroring after configuring mirroring?

Ans: Yes it is possible, by using above mechanism

11.  What is the major difference between Merge replication and Transactional replication?

Ans: In Merge replication the both publisher and subscriber can work independently

12.  How to resolve conflicts in merge replication?

13.  What is quorum in clustering?

14.  What happened when quorum gone?

15.  Is it possible to start service when quorum is gone?

Ans: -No quorum

16.  How to take backup of 400GB DB with in less time?

Ans: Generally 1 GB take 1 min, If we use stripped backups we can reduce time, If we have 4 processors and 4 drives.

17.  How to find what are the driver’s available in our machine?

Ans: EXEC master.sys.xp_fixeddrives

18.  What is check point?

Ans:Check point is raised when we take backup of database or restarting sql server service

19.  Is it posible to raise chaeckpoint our self?

Ans:Yes

sp_configure 'recovery interval', 32767

go

reconfigure with override

20.  What is the difference between procedure and function?

21.  How to call procedure?

22.  What is the advantage of recompile statement in procedure?

Ans: I have noticed that after inserting many rows in one table many times the stored procedure on that table executes slower or degrades. This happens quite often after BCP or DTS. I prefer to recompile all the stored procedure on the table, which has faced mass insert or update. sp_recompiles marks stored procedures to recompile when they execute next time.

23.  How to know the current connected connections?

24.  How to set maximum connections?

Ans: SP_Configure

25.  How to start sql service without raising checkpoint?

SHUTDOWN WITH NOWAIT

26.  Have you work on cmd prompts?

Ans:

Runà CMDà net start mssqlserver

Runà CMDà net stop mssqlserver

27.  What is transaction?

Ans: IT is nothing but sequence of actions

28.  Can you say syntax of transaction?

Ans: Begin Tran

           Statements

        Commit Tran

 

29.  What is difference between cascade drop of table?

Ans: Cascade option allows the user to delete all the tables which are defined by foreign key relation

 

30.  What happened if we issue drop table command?

Ans: If the tables are involved in foreign key relation, if we try to delete those tables. It will not allow deleting. If we delete under any circumstances we define that as cascade

 

31.  What are the several recovery models?

Ans: Full, simple, Bulk logged recovery model

 

32.  Why log shipping is not supported in simple recovery model?

 

33.  What is the default port for mirroring?

Ans: 5022

 

 

34.  How to change default port for sqlserver?

Ans: Go to sqlserver configuration managerà serviceà protocolsà choose TCP/IPà right clickà Take propertiesà Go to advancedà Change IP for which are not loop backed ip

35.  What is resource governor?

36.  What is heart beating in clustering?

37.  Which cable is used for heart beat, Is it cross cable or plain cable?

 ANS: Cross cable

 

38.  What are the different types of indexes?

39.  What are the limits for cluster and non cluster indexes? ANS: 1- 255

40.  Why we have only one cluster index for table?

41.  What is the importance of statistics?

42.  Scenario: My server running fast upto the yester day, today onwords slows, As a DBA what you have to do?

43.  How to find what are the queries that are running in particular SPID?
sys.dm_exec_sql_text

44.  How to find sql server version?

Ans: select @@version

45.  What is another port number for sqlserver?

Ans: for TCP/IP: 1433, UDP: 1434

46.  I have backup and I want to restore upto particular time only?

Ans: Restore database wowzzy to disk=’’ with stopat=’time stamp’

47.  How to create user, how to assign read and write permissions only for that user?

48.  What is Super admin, who is having total rights in system level? Ans: SA

49.  What is full form of SA? Ans: System Administrator

50.  What are the different locks?

51.  What are different isolation levels?

52.  What is serelizable?

53.  What is exclusive lock?

54.  I have done some schema change (Add column for table) in merge replication for an article, is it applied for subscriber?

55.  Can you list some system tables?

         56.Difference between shrink and truncate?

o    Truncate cannot remove empty space

o    Shrink can remove empty space, so space can recollect

SQL DBA interview questions+ Infosys

1.     What is your backup strategy?

2.     What is quorum?

3.     How to install quorum?

4.     What is DMV?

5.     What normalization?

6.     Solve backup failure scenario?

7.     How many instances are there for your production box?

8.     How to create Login?

9.     How many CPU’s are there for your environment?

10.  What is the size of DB?

11.  What are differences between sql server 2000 to sql server 2005?

12.  What are the different versions in sql server?

13.  What is your current version?

Monday, May 13, 2013

SQL Server Devloper Interview Questions + Altech Sysytems

1. what is normalization? Explain different forms of normal forms? BCNF ?

2.CODD Rules? De-normalization? where we use de-normalizaion?

3.what is E-R Diagrams and DFDs?explain exapmle for each one.

4.What is the select statement order in the DB?

The below is the (general) order of evaluation. Column Aliases are only available from step 5 onwards so are usable in ORDER BY but not WHERE

(5) SELECT (6) DISTINCT
(1) FROM
(2) WHERE
(3) GROUP BY
(4) HAVING
(7) ORDER BY
 
5.What is the difference between stored function and stored procedure?syntax for each of them .what is the advantage of 
  stored procedure?
 
6.What is the primary key,unique & foregin key?

7.Different types of joins?exlain example for each one.

8.What is subquery?explain the concept of subquery.

9.What is the difference between clustered index and non-clustered index?

10.What is the local and global temporary tables .example for each?

11.How to rename of a DB,rename of a table & rename of a column? 
 
12.How to use 1-1,1-M,M-M in the design of tables?
 
13.Cursor?syntax of a cursor?what is the alternative way of cursor in the business world? .

14.what is the ROWGUIDCOL?

15.what is the prevention of Referential integrity?
16.what is the exporting & importing in DB?syntax.
17.what is the trigger?Nested Trigger.
18.what is the user defined datatype,in which situation UDT used?.
19.what is the transaction?ACID properties.
20.what is the DB backup & restore ,shrink DB?
21.How to handle errors in sql serevr 2008? What is RAISEERROR.



E. F. Codd's Rules

Dr. E. F. Codd's 12 rules

for defining a fully relational database

Note that based on these rules there is no fully relational database management system available today. In particular, rules 6, 9, 10, 11 and 12 are difficult to satisfy.

  1. Foundation Rule
    A relational database management system must manage its stored data using only its relational capabilities.


  2. Information Rule
    All information in the database should be represented in one and only one way - as values in a table.


  3. Guaranteed Access Rule
    Each and every datum (atomic value) is guaranteed to be logically accessible by resorting to a combination of table name, primary key value and column name.


  4. Systematic Treatment of Null Values
    Null values (distinct from empty character string or a string of blank characters and distinct from zero or any other number) are supported in the fully relational DBMS for representing missing information in a systematic way, independent of data type.


  5. Dynamic On-line Catalog Based on the Relational Model
    The database description is represented at the logical level in the same way as ordinary data, so authorized users can apply the same relational language to its interrogation as they apply to regular data.


  6. Comprehensive Data Sublanguage Rule
    A relational system may support several languages and various modes of terminal use. However, there must be at least one language whose statements are expressible, per some well-defined syntax, as character strings and whose ability to support all of the following is comprehensible:
    1. data definition
    2. view definition
    3. data manipulation (interactive and by program)
    4. integrity constraints
    5. authorization
    6. transaction boundaries (begin, commit, and rollback).

  7. View Updating Rule
    All views that are theoretically updateable are also updateable by the system.


  8. High-level Insert, Update, and Delete
    The capability of handling a base relation or a derived relation as a single operand applies nor only to the retrieval of data but also to the insertion, update, and deletion of data.


  9. Physical Data Independence
    Application programs and terminal activities remain logically unimpaired whenever any changes are made in either storage representation or access methods.


  10. Logical Data Independence
    Application programs and terminal activities remain logically unimpaired when information preserving changes of any kind that theoretically permit unimpairment are made to the base tables.


  11. Integrity Independence
    Integrity constraints specific to a particular relational database must be definable in the relational data sublanguage and storable in the catalog, not in the application programs.


  12. Distribution Independence
    The data manipulation sublanguage of a relational DBMS must enable application programs and terminal activities to remain logically unimpaired whether and whenever data are physically centralized or distributed.


  13. Nonsubversion Rule
    If a relational system has or supports a low-level (single-record-at-a-time) language, that low-level language cannot be used to subvert or bypass the integrity rules or constraints expressed in the higher-level (multiple-records-at-a-time) relational language.

De-Normalization in SQL Server

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.


* Many critical queries and reports exist which rely upon data from more than one table. Often times these requests need to be processed in an on-line environment.

* Repeating groups exist which need to be processed in a group instead of individually.

* Many calculations need to be applied to one or many columns before queries can be successfully answered.

* Tables need to be accessed in different ways by different users during the same timeframe.

* Many large primary keys exist which are clumsy to query and consume a large amount of DASD when carried as foreign key columns in related tables.

* Certain columns are queried a large percentage of the time. Consider 60% or greater to be a cautionary number flagging de-normalization as an option.

Normalization in SQL Server

                       Normalization is the process of efficiently organizing data in a database. There are two goals of the normalization process: eliminating redundant data (for example, storing the same data in more than one table) and ensuring data dependencies make sense (only storing related data in a table). Both of these are worthy goals as they reduce the amount of space a database consumes and ensure that data is logically stored.

The Normal Forms

                        The database community has developed a series of guidelines for ensuring that databases are normalized. These are referred to as normal forms and are numbered from one (the lowest form of normalization, referred to as first normal form or 1NF) through five (fifth normal form or 5NF).

First Normal Form (1NF)

First normal form (1NF) sets the very basic rules for an organized database:
  • Eliminate duplicative columns from the same table.
  • Create separate tables for each group of related data and identify each row with a unique column or set of columns (the primary key).
  •  
  • Second Normal Form (2NF)

  • Second normal form (2NF) further addresses the concept of removing duplicative data:
  • Meet all the requirements of the first normal form.
  • Remove subsets of data that apply to multiple rows of a table and place them in separate tables.
  • Create relationships between these new tables and their predecessors through the use of foreign keys.

Third Normal Form (3NF)

Third normal form (3NF) goes one large step further:
  • Meet all the requirements of the second normal form.
  • Remove columns that are not dependent upon the primary key.
  • Imagine that we have a table of widget orders that contains the following attributes:
    • Order Number
    • Customer Number
    • Unit Price
    • Quantity
    • Total
 Remember, our first requirement is that the table must satisfy the requirements of 1NF and 2NF. Are there any duplicative columns? No. Do we have a primary key? Yes, the order number. Therefore, we satisfy the requirements of 1NF. Are there any subsets of data that apply to multiple rows? No, so we also satisfy the requirements of 2NF.

Now, are all of the columns fully dependent upon the primary key? The customer number varies with the order number and it doesn't appear to depend upon any of the other fields. What about the unit price? This field could be dependent upon the customer number in a situation where we charged each customer a set price. However, looking at the data above, it appears we sometimes charge the same customer different prices. Therefore, the unit price is fully dependent upon the order number. The quantity of items also varies from order to order, so we're OK there.

What about the total? It looks like we might be in trouble here. The total can be derived by multiplying the unit price by the quantity, therefore it's not fully dependent upon the primary key. We must remove it from the table to comply with the third normal form. Perhaps we use the following attributes:
  • Order Number
  • Customer Number
  • Unit Price
  • Quantity
Now our table is in 3NF. But, you might ask, what about the total? This is a derived field and it's best not to store it in the database at all. We can simply compute it "on the fly" when performing database queries. For example, we might have previously used this query to retrieve order numbers and totals:

 SELECT OrderNumber, Total
 FROM WidgetOrders
 
We can now use the following query:

 SELECT OrderNumber, UnitPrice * Quantity AS Total
 FROM WidgetOrders
 
 

Boyce-Codd Normal Form (BCNF or 3.5NF)

The Boyce-Codd Normal Form, also referred to as the "third and half (3.5) normal form", adds one more requirement:
  • Meet all the requirements of the third normal form.
  • Every determinant must be a candidate key.
 
Examples: 
Conisder a database table that stores employee information and has the attributes employee_id, first_name, last_name, title. In this table, the field employee_id determines first_name and last_name. Similarly, the tuple (first_name, last_name) determines employee_id.
 
 
 
Examples with Explanation:
 
 
1.    1NF (Eliminating Repeating Groups)

•    Make a separate table for each set of related attributes and give each table a primary key. 
 
In simple words I can say it as

•    There are no repeating or duplicate fields.

•    Each cell contains only a single value.

•      Each record is unique and identified by primary key

Let’s see the example below :

Prior to Normalization

Item    Colors         Price    Tax

Pen       red, blue        2.0        0.20

Scale     red, yellow     2.0       0.20

Pen        red, blue       2.0        0.20

Bag      blue, black    150.00    7.80 
 
This table is not in first normal form because:

 •      A. There are multiple fields in color lab.

 •      B. Records are repeating (Duplicate records) or no primary key.

First Normal Form (1NF)

Item    Colors    Price    Tax

Pen         red         2.0          0.20

Pen        blue        2.0         0.20

Scale       red       2.0         0.20

Scale      yellow    2.0        0.20

Bag        blue      150.00    7.80

Bag       black      150.00    7.80

•    This table is now in first normal form. 



2.    2 NF (Eliminating Redundant Data)

•    If an attribute is dependent on only part of the multivalued key, then remove it to a separate table.


 In simple words,
•    It should meet all the requirements of the first normal form.
.  It should remove subsets of data that apply to multiple rows of a table and place them in separate tables.
.  It create relationships between these new tables and their predecessors through the use of foreign keys.
The First Normal form deals with the atomicity whereas the Second Normal Form deals with the relationship between the composite key columns and non-key columns. To achieve the next progressive level your table should satisfy the requirement of First Normal Form then move towards the Second Normal Form.
Let’s introduce a Review table as an example :
Item    Colors    Price    Tax
Pen        red           2.0        0.20
Pen        blue          2.0        0.20
Scale       red         2.0         0.20
Scale       yellow    2.0        0.20
Bag         blue       150.00    7.80
Bag        black    150.00    7.80
Table is not in Second Normal Form because the price and tax depends on the item, but not color.
Item    Colors
Pen    red
Pen    blue
Scale    red
Scale    yellow
Bag    blue
Bag    black

Item    Price    Tax
Pen        2.0         0.20
Scale      2.0        0.20
Bag     150.00     7.80
Tables are now in Second Normal Form.


3.    3NF (eliminate Columns not dependent on the Key)
•    If attributes do not contribute description of the key, then remove it to the separate table. All the attributes must be directly dependent on the primary key. In simple words,
•    It should meet all the requirements of the second normal form.
•     It should remove columns that are not dependent upon the primary key.
In the Third Normal Form all columns depend upon the primary key. When one column depends upon the other column, tables break the rule and turn into the dependency on the primary key.


Item    Colors
Pen        red
Pen      blue
Scale    red
Scale    yellow
Bag      blue
Bag      black

Item    Price    Tax
Pen        2.0    0.20
Scale       2.0    0.20
Bag       150.00    7.80
Tables are not in Second Normal Form because tax depends on price, not item.
Item      Colors
Pen         red
Pen         blue
Scale      red
Scale      yellow
Bag       blue
Bag       black

Item       Price
Pen          2.0
Scale       2.0
Bag          150.00

Price       Tax
2.0           0.20
150.00     7.80

Tables are now in Third Normal Form.