SQL Server 2008 Auditing Functionality

SQL Server 2008 in-built Auditing Functionality has a lot of advantages over traditional way of auditing:

1. SQL Server 2008 Auditing is Easy to Setup and Administer.
2. SQL Server 2008 Auditing can be enable at the Instance and Database Levels.
3. SQL Server 2008 Auditing includes many predefined activities that you can audit, including DML and DDL activity.
4. SQL Server 2008 Auditing is very lightweight compared to older ways of capturing this information which used Traces. It internally uses Extended Events engine to capture audit data. This results in fast performance plus minimum overhead compared to using SQL Trace to capture activity.
5. SQL Server 2008 Auditing has a high Granularity in auditing … Read the rest

Recycling SQL Error Log and increasing max number of Error logs Stored

Recycling Error log is another important thing in case if you are storing login auditing with login success to Error log. With Recycling error log to avoid losing important data one should increase the number of Error logs stored.

For Example: If Error log is growing at a rapid level then it can be recycled every two days and its setting can be changed to keep 50 error log files or higher which would account around 100 days.
1. Set the number of log files to 50 from the default of 6 to do this:
• SQL 2005 – Right click on SQL Server logs folder in Managment studio and choose Configure from the pop … Read the rest

Setting up and Monitoring of Database Mirroring as DR Strategy

Quick Step by Step Procedure involved:

• Perform a full backup of the database on the Principal server.
• Perform a Transaction Log backup on the Principal server.
• Copy the backup file to the Mirror.
• Do a restore of the full backup into a new step, but before doing the restore, go to Options, then ensure you check the No Recovery option
• Perform another restore of the Transaction Log, also with the No Recovery option.
• Go to the Database Properties on individual databases and choose the Mirroring tab.
• Click “Configure Security”
• Click Next on the wizard
• Choose not to have a Witness server since Asynchronous Database Mirroring is used.
• Click Next
• … Read the rest

Dynamic Management Views in SQL Server

Dynamic Management Views in SQL Server exists in SYS schema and their names start with DM_.
To query a DMV, we should prefix the view name with SYS.
Ex: To know total physical memory of the SQL Server we can use:

SELECT
(Physical_memory_in_bytes/1024.0)/1024.0 AS Physical_memory_in_Mb
FROM
sys.dm_os_sys_info

The Mostly used DMV’s to check the current behaviour of SQL Server are:
1. SQL Server related/Hardware Resources DMV
2. Database related DMV
3. Index related DMV
4. Execution related DMV
1. SQL Server Related DMV
This section details the DMV’s associated with SQL Server system.
Below are some of the DMV’s which are related to OS, Disk and Memory.
i.sys.dm_os_sys_info
This view returns the information about the SQL Server machine, available … Read the rest

Creating a Central Management Datawarehouse in SQL Server 2008

What is the Management Data Warehouse?
The Management Data Warehouse(MDW) is a single database/Data Warehouse created inside of a SQL Server 2008 instance, which holds various performance related statistics. The performance statistics in the MDW are gathered via special data gathering routines, known as Data Collections. The MDW can contain Data Collection information from a single instance, or it can hold data collected from multiple instances(Steps shown at the end). The Data Collection process uses SSIS and SQL Agent jobs to gather, schedule and purge information in the MDW.

SQL Server 2008 provides three different system Data Collection definitions. These Data Collections are Disk Usage, Query Activity, and Server Activity. Each of these Data Collection definitions identifies the data that … Read the rest

SQL 2008 Transactional Replication and initializing from a backup file

In some environments,running Fresh snapshot will take ages to synchronise the subscribers with publishers. Even if it is done in low activity hours, it will run into business hours because of time takes to take snapshot, copy, restoring snapshot, synchronising transactions again.
There is way in which the replication can be setup by initialising using a backup in SQL Server 2008. This new feature is very useful in environments where it takes a lot of time to run a fresh Snapshot/Re-initialise the replication.
I have followed a following set of steps in setting this up and testing:

Step No Steps Followed
1 Set up the Distributer (This applies to fresh Replication where a database and share to be setup)
2
Read the rest

SQL Server Resource Governor

Microsoft has introduced an interesting and exciting new feature in SQL Server 2008; it is named the Resource Governor. It allows the user to limit the CPU and memory usage by a specific application or user. It would help in preventing any particular user / application to eat up all the resources of the SQL Server.
Terminologies:
Resource Pool
It is the collection of physical resources of the database management system. It is viewed as a virtual SQL Server instance within the SQL Server as visible by the application. It is defined with minimum and maximum values of resource (memory and CPU) utilization. SQL Server 2008 allows a maximum of 18 user defined pools and two built-in pools. There are … Read the rest

SQL Server Memory

SQL Server divides the total memory dedicated to it into two parts referred to as Buffer Pool and Memory to Leave.
Buffer Pool is the larger of the two and is used for most memory operations like stored procedure query plan generation, caching data and creating indexes.
Memory to Leave is dedicated to executing linked server queries, extended stored procedure calls and OLE automation procedure calls. By default, Memory to Leave is 384 MB and the balance of total memory available to SQL Server will determine the size of Buffer Pool.
An important counter of the performance of buffer cache is the Buffer Cache Hit Ratio performance counter. It indicates the percentage of data pages found in the buffer cache … Read the rest

SQL Server Tempdb Management

Some Facts about TempDB
The tempdb is a temporary workspace which is normally used for:
• Storage of explicitly created temporary tables.
• Worktables that hold intermediate results created during query processing and sorting.
• Materialized static cursors.
SQL Server records only enough information in the tempdb transaction log to roll back a transaction but not to redo transactions during database recovery. This feature increases the performance of INSERT statements in the tempdb. In addition, there is no need to log information to redo any transactions because the tempdb is re-created every time you restart SQL Server.
Therefore, it does not have any transactions to roll forward or roll back. When SQL Server starts, the tempdb is re-created by using … Read the rest

SQL Server Optimistic Concurrency

SQL Server Concurrency Terminology
Optimistic concurrency control inside the SQL Server 2005/2008 database engine technically means that row versioning is used instead of a pessimistic locking approach. I believe this is a source of much confusion to both application developers and DBAs because row versioning isn’t required for applications to use optimistic concurrency control by using hints like (nolock).
Applications have used optimistic concurrency long before row versioning was introduced in SQL Server 2005/2008. In fact, the rowversion data type (a.k.a. timestamp) exists specifically to facilitate optimistic concurrency control.

Choosing the SQL Server concurrency control features (transaction isolation levels, transactions, locking hints) that are most appropriate for the task at hand without getting tripped up on terminology. For example, SQL … Read the rest