Sunday, January 24, 2010

DBCC Commands By Category

Informational:
DBCC INPUTBUFFER 
DBCC SHOWCONTIG 
DBCC OPENTRAN 
DBCC SQLPERF 
DBCC OUTPUTBUFFER 
DBCC TRACESTATUS 
DBCC PROCCACHE 
DBCC USEROPTIONS 
DBCC SHOW_STATISTICS
 
Validation:
DBCC CHECKALLOC

DBCC CHECKFILEGROUP

DBCC CHECKCATALOG

DBCC CHECKIDENT

DBCC CHECKDB

Maintenance:
DBCC CLEANTABLE 
DBCC INDEXDEFRAG
DBCC DBREINDEX 
DBCC SHRINKDATABASE 
DBCC DROPCLEANBUFFERS 
DBCC SHRINKFILE 
DBCC FREEPROCCACHE 
DBCC UPDATEUSAGE

Miscellaneous: 
DBCC DLLNAME
DBCC HELP
DBCC TRACEON
DBCC TRACEOFF
sql server dba dbcc commands. all dbcc commands list. sql server 2012 dbcc commands. all dbcc list. sql server 2008 r2 dbcc commands. sql server 2005 dbcc commands. sql server dbcc help. dbcc. dbcc usage. new dbcc commands. dbcc list. dbcc category.

Thursday, January 7, 2010

Components, Used Terms, and Brief Working Of Replication In SQL Server

What is Replication?

Replication is a set of technologies for copying and distributing data and database objects from one database to another and then synchronizing between databases to maintain consistency. Using replication, you can distribute data to different locations and to remote or mobile users over local and wide area networks, dial-up connections, wireless connections, and the Internet.

What are the Components in Replications? 

Publisher: A publisher is any database unit that makes data available to other sources via replication. The publisher can have multiple publications which defines the data to replicate.

Subscriber: A subscriber is any database unit that receives the replicated data. It can receive data from multiple publishers or publications. Data can be republished to the other subscribers.

Article: Article is the basic unit of publication. It shows what is published. An article can simply be a table or a stored procedure. When tables are used as articles, filters can be used to restrict the columns and rows of the data sent to Subscribers.

Publication: It is a collection of one or more articles from one database.

Distributor: A distributor is any database unit that acts as a store for the data to be replicated. Each publisher is associated with a single database called as distribution database. Replication status data is stored in distribution database. A distributor can be local or remote.

Pull Subscription: In a pull subscription, changes to a subscriber cannot be publicized without any request from subscriber. This allows the user at the Subscriber to determine when the data changes are synchronized.

Push Subscription: In a push subscription, changes to a subscriber can be publicized without any request from subscriber. The changes can be pushed either periodically or on demand.

Snapshot Agent: A snapshot agent is used in snapshot replication. Snapshots can be created as soon as the subscription is created. The snapshot agent prepares snapshot files that contain details of the published data. The snapshot also assists in establishing connection from the Distributor to the Publisher.

Log Reader Agent: The replication Log Reader Agent is an executable that is used for monitoring transaction logs of each database. It c copies the transactions marked for replication from the transaction log into the distribution database.

Distribution Agent: The distribution Agent is an executable that is used to move the snapshot and the transactions held in the distribution database tables to the destination tables at the Subscribers.

Merge Agent: The replication merge agent is an executable that is used to apply the database snapshot to the subscriber. After the initial snapshot, any other changes if made are also merged.

Queue Reader Agent: The Replication Queue Reader Agent is an executable that is used to read messages stored in a Microsoft SQL Server queue or a Microsoft Message Queue and then applies those messages to the Publisher.

What are the terms used in Replication?


Publisher is the database that transmits its data to another database.
 

Subscriber is the database that receives data from another database.
 

Distributor manages the flow of data during data replication.
 

Push subscription is the subscription when data is pushed from publisher database to subscribing database.
 

Pull subscription is subscription when the subscribing database pulls the data from distribution database.
 

Distribution database is the system database that stores snapshot jobs to be distributed to subscribers.

Describe in brief working of Replication?
  1. At first data and object is synchronized between publisher and subscribers.
  2. The snapshot is created on the publisher and transmitted to subscribers.
  3. All the subsequent changes on the publisher are stored in distribution database.
  4. Subscriber receives the data either using push or pull mechanism as configured from distribution database
What is Publisher. What is Subscriber. What is Article. What is Publication. What is Distributor. What is Pull Subscription. What is Push Subscription. What is Snapshot Agent. What is Log Reader Agent. What is Distribution Agent. What is Merge Agent. What is Queue Reader Agent. What is replication. how to configure replication. What are the terms used in Replication?. replication interview question and answers. interview question and answers. sql server 2012 replication interview question and answers. experienced dba interview question and answers. Distribution database. system database. replication configuration steps. most asked questions in interview. ibm interview question and answers. wipro interview question and answers. tech mahindra interview question and answers. replication types. replication usage. sql server 2008 r2 replication. sql server 2000 replication. sql server 2005 replication. sql server 2012 replication. snapshot replication. transactional replication. merge replication. queue update replication. 

Monday, January 4, 2010

More About CXPACKET Wait Stats

What is CXPACKET Wait Stats?
When Query executing in Parallel Operation then there are multiple threads for a single query. Each thread deals with a different set of data. Some threads finish fast and some threads finish slow then CXPACKET Wait Stats will create.

Threads which came first have to wait for slow threads to fnish, the wait by a finished thread is called CXPACKET Wait Stat.

All the CXPACKET wait types are bad. If you remove wait type for any query, then that query run slower because the parallel operations are disabled for that query or if you run entire query in a single CPU you will experienced very bad

How to Change MAXDOP at Server Level

EXEC SP_Configure N'max degree of parallelism', N'1'
GO
RECONFIGURE WITH OVERRIDE
GO

The best suggestion is set ‘the maximum degree of parallelism’ to a lower number or half the number of CPU's

NOTE: The server level setting Can be overwritten on a query level.



whats the use of maxdop in sql server 2005. whats the use of maxdop in sql server 2008 r2. whats the use of maxdop in sql server 2012. how to configure maxdop in sql server 2012. how to use maxdop in sql server through query. how to use maxdop in a query. what is threads. what is CXPACKET. what is cxpacket in sql server 2008. what is cxpacket in sql server 2012. what is the use of cxpacket in sql server 2012. how to avoid cxpacket error. how to resolve cxpacket error. Reducing CXPACKET Wait Stats for High Transactional Database. CXPACKET Parallelism. A closer look at CXPACKET wait type in SQL Server. cxpacket wait cxpacket sql server 2008. cxpacket suspended. cxpacket e_waitpipegetrow. cxpacket parallelism. cxpacket exchangeevent. cxpacket lock. cxpacket maxdop.

Sunday, January 3, 2010

SQL Server Database Administrator Interview Questions and Answers Series 11

What is database replication? What are the different types of replication you can set up in SQL Server?
Replication is the process of copying or moving of data between databases on the same or different servers. 

SQL Server supports the following types of replication scenarios: 
1. Snapshot replication 
2. Transactional replication (with immediate updating subscribers, with queued updating subscribers) 
3. Merge replication 

What is Snapshot ReplicationIn snapshot replication a snapshot of entire data is copied from publisher to the subscriber's database on regular interval. This kind of replication is used for replicating data that doesn’t change frequently. This replication is considered when amount of data to be replicated is small.

What is Merge ReplicationIn merge replication allows both publisher and subscriber to work independently, online or offline and merges the changes later. In this merge replication changes are track on both publisher and subscriber and then merged.

What is Transactional ReplicationTransactional replication is used when changes are frequent.
The replication agent monitors the changes at the publisher and distributes the changes to the subscribers. Transactional Replication is required where up to date data is required
 


Define the terms used in Replication.
Publisher:- Publisher is the database that transmits its data to another database.
Subscriber:- Subscriber is the database that receives data from another database.
Distributor:- Distributor manages the flow of data during data replication.
Distribution Database:- Distribution database is the system database that stores snapshot jobs to be distributed to subscribers. 
Push Subscription:- Push subscription is the subscription when data is pushed from publisher database to subscribing database.
Pull Subscription:-
Pull subscription is subscription when the subscribing database pulls the data from distribution database.

Describe the replication agents that SQL Server supports.
Snapshot Agent
Log Reader Agent
Distribution Agent
Merge Agent
 

The Snapshot Agent creates snapshot files and stores on the distribution database. It also keeps track of synchronization status in the distribution database. This is used in all kinds of replication.

The Log Reader Agent moves transactions marked for replication from the transaction log on the Publisher to the distribution database. This is used in transactional replication.

The Distribution Agent moves the snapshot jobs from the distribution database to Subscribers. This is used in Merged and transactional replication.

The Merge Agent is an agent of merge replication that merges incremental data changes that have occurred since the initial snapshot was created 



Describe in brief working of Replication. 1.  At first data and object is synchronized between publisher and subscribers.
2. 
The snapshot is created on the publisher and transmitted to subscribers.3.  All the subsequent changes on the publisher are stored in distribution database.
4. 
Subscriber receives the data either using push or pull mechanism as configured from distribution database   


Can you explain in detail how transactional replication works?
Transactional replication is implemented by the SQL Server Snapshot Agent, Log Reader Agent, and Distribution Agent. 


1.  The Snapshot Agent prepares snapshot files containing schema and data of published tables and database objects, stores the files in the snapshot folder, and records synchronization jobs in the distribution database on the Distributor.
2.  The Log Reader Agent monitors the transaction log of each database configured for transactional replication and copies the transactions marked for replication from the transaction log into the distribution database, which acts as a reliable store-and-forward queue. 
3.  The Distribution Agent copies the initial snapshot files from the snapshot folder and the transactions held in the distribution database tables to Subscribers.
4.  Incremental changes made at the Publisher flow to Subscribers according to the schedule of the Distribution Agent, which can run continuously for minimal latency, or at scheduled intervals. 
5.  Because changes to the data must be made at the Publisher (when transactional replication is used without immediate updating or queued updating options), update conflicts are avoided. 
6.  Ultimately, all Subscribers will achieve the same values as the Publisher. 
7.  If immediate updating or queued updating options are used with transactional replication, updates can be made at the Subscriber, and with queued updating, conflicts might occur.  


What are data type concerns during replications?
1.  If it’s a transactional replication you have to include a “Timestamp” column.
2.  If it’s merge replication you will need a “uniqueidentifier” column.


What are the advantages and disadvantages of using Snapshot replication?
Advantages:-
1.  Simple to setup. If the database is small or you only want to replicate master data (State code, Pin code etc) it’s the best approach, as these values do not change heavily.
2.  If you want to keep a tight control over when to schedule the data this is the best approach.
For example you will like to replicate when the network traffic is low (probably during Saturday and Sunday).

Disadvantages:
1.  As data start growing the time taken to complete the replication will go on increasing.
2.  Snapshot Replication It is like a Backup and Restore, and every time snapshot re-write the DB. Only Differance is It will take Specified articles which are Published.
3.  By default the behavior is to drop the table and recreate and then bulk copy in the data. The level of locking you will see will be similar to when you bcp in data into a table.
Please check these interview questions as well. 
[SQL Server Database Administrator Interview Questions and Answers - Part #12] 
Tags: sql server interview questions. sql server 2008 interview questions. sql server 2008 interview questions and answers . sql server interview questions and answers for experienced. sql server interview questions and answers for freshers. sql server interview questions and answers. sql server dba interview questions and answers. sql server dba interview questions. sql server database administration interview questions . sql server 2008 database administration interview questions. sql server 2012 interview question and answers. sql server 2012 FAQ. sql server 2012 dba interview. sql dba 2012 interview question and answers. sql server 2008 r2 interview question and answers. sql 2012. sql 2008 r2. sql 200 r2 interview question and answers. sql server question and answers. sql server developer interview question and answers. sql developer interview question and answers.  sql server interview questions. sql server 2008 interview questions. sql server 2008 interview questions and answers. sql server interview questions and answers for experienced. sql server interview questions and answers for freshers. sql server interview questions and answers. sql server dba interview questions and answers. sql server dba interview questions. sql server database administration interview questions. sql server 2012 database administration interview questions. sql server interview questions for entry level. sql server interview questions for experienced.