Page 1 of 212

SQL Queries for DMVs

Posted by Sagar Patil

image

Read more…

tempdb shrink error : File ID of database was skipped because the file does not have enough free space to reclaim

Posted by Sagar Patil

 

Read more…

SQL Server logs, changing level of logging

Posted by Sagar Patil

To view SQL Server error log from SQL Server Enterprise Manager
- Expand a server group, and then expand a server.
- Expand Management, and then expand SQL Server Logs.
- Click the SQL Server Log to view it. Error log information appears in the details pane

Read more…

How to truncate SQL Server Transaction Log

Posted by Sagar Patil

Step 1.  Find Size of Database Log files

SELECT DB_NAME(database_id) AS DatabaseName,
Name AS Logical_Name,
Physical_Name, (size*8)/1024 SizeMB
FROM sys.master_files
WHERE DB_NAME(database_id) like ‘%AdventureWorks%’
and name like ‘%Log%’
order by SizeMB desc

Read more…

SQL Server Permissions of Fixed Database Roles

Posted by Sagar Patil

Fixed database roles can be mapped to the more detailed permissions that are included in SQL Server.

SQL Server Error Messages

Posted by Sagar Patil

SQL Server comes with pre-defined error messages that can be raised when a particular condition occurs. Built-in error messages are stored in the sysmessages table of the master database. Depending on the severity level, error messages can be returned to the offending connection or could be recorded in the SQL Server error log. The severity level determines the type and seriousness of the problem that caused the error. The following table summarizes various error severity levels: Read more…

SQL server SQLDIAG Utility

Posted by Sagar Patil

SQLDIAG.exe executable can be found in the SQL Server installation directory under the BINN folder. SQLDIAG records the SQL Server configuration, contents of the error logs (current, as well as archived logs), and Windows configuration including registry keys. If SQL Server is running when SQLDIAG is executed, it will record the output of the following routines: Read more…

SQL Server | How to create a Read Only User/Role

Posted by Sagar Patil

I have number of SQL server databases and users . I am in a need to create read only access to users who wants to look at data. Read more…

TSQL | Delete All Objects from Database

Posted by Sagar Patil

Often I have to copy number of SQL server database structures from prod system for testing. It’s difficult to get rid of all objects within a database manually. Following script will do just about that.

Read more…

What patches are applied to my SQL Server

Posted by Sagar Patil

Use

  • select @@VERSION”  OR
  • SELECT SERVERPROPERTY(‘productversion’), SERVERPROPERTY (‘productlevel’), SERVERPROPERTY (‘edition’) ” Or
  • Simply look at the value in the Management Studio Explorer

Read more…

How to use SP_CONFIGURE in SQL Server

Posted by Sagar Patil

sp_configure is a tool to display and change SQL Server settings. Please be aware that changing these settings can dramatically affect your instance.

Read more…

SQL Server Maintenance Scripts : YourSqlDba & SQL Server Maintenance Solution

Posted by Sagar Patil

If you are looking for a good TSQL packaged scripts which will do usual database maintenance activities then you are on right page. I have detailed 2 such projects which will help you to setup maintenance job in less than an hour.

Read more…

How to create a new named instance under SQL 2005/2008

Posted by Sagar Patil

We can only configure one default instance under SQL server installation.  If we need additional instance  it should be a named instance.

Read more…

How to locate SQL server clustered database & it’s properties

Posted by Sagar Patil

 

1. How to locate if I am connected to a SQL server cluster?

SELECT SERVERPROPERTY(‘IsClustered’)

Read more…

SQLIO SAN/Local Disk Subsystem Benchmark Tool

Posted by Sagar Patil
  1. Download http://www.microsoft.com/downloads/details.aspx?familyid=9a8b005b-84e4-4f24-8d65-cb53442d9e19&displaylang=en and install SQLIO
  2. It will be installed under C:\Program Files\SQLIO. Please add this directory in your FIle Path
  3. SQLIO will need a test file to run against your drives for performance.

Read more…

Database Engine Tuning Advisor : how to Import SQL profiler traces at DTA

Posted by Sagar Patil

Let’s create a TRACE for Performance Analysis

USE [Test]
GO
/****** Object: Table [dbo].[Person] Script Date: 07/30/2009 15:33:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Person](
[ID] [int] NOT NULL,
[First] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
[last] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
[County] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
CONSTRAINT [PK_Person] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

Read more…

Query Performance : Enable execution plan /IO stastics under SQL server

Posted by Sagar Patil

Enable IO and Explain Plan settings using “set options”

Read more…

SQL Server : How to Enable Intra Query Parallelism

Posted by Sagar Patil

Right click on “server name” and select “properties”

Read more…

Troubleshooting Bottlenecks Using Dynamic Memory Views : Part III

Posted by Sagar Patil
  1. Windows System Monitor – PART I
  2. DBCC commands – PART II
  3. Dynamic Memory Views - PART III
  4. SQL Server Profiler – - PART IV

Read more…

Troubleshooting Bottlenecks : Using SQL Server Profiler & Windows System Monitor Together

Posted by Sagar Patil

Here is a situation – users are complaining about a slow SQL server response.

We want to quantify if that is result of a hard hitting SQL query or this is to do with some application/background jobs running on the server.

Let’s put to practise our skills from http://www.oracledbasupport.co.uk/troubleshooting-bottlenecks-using-sql-server-profiler-part-iv/ & http://www.oracledbasupport.co.uk/troubleshooting-bottlenecks-using-windows-system-monitor-part-i/

Please initiate a Trace on SQL server before going ahead. Within a SQL server Profiler window click on the top button for “Performancve Monitor” to enable logging.

Read more…

Troubleshooting Bottlenecks Using SQL Server Profiler : PART IV

Posted by Sagar Patil
  1. Windows System Monitor – PART I
  2. DBCC commands – PART II
  3. Dynamic Memory Views - PART III
  4. SQL Server Profiler – - PART IV

SQL Server Profiler – - PART IV


Read more…

Troubleshooting Bottlenecks Using Windows System Monitor : Part I

Posted by Sagar Patil
  1. Windows System Monitor – PART I
  2. DBCC commands – PART II
  3. Dynamic Memory Views - PART III
  4. SQL Server Profiler – - PART IV

Windows System Monitor

Read more…

Backups and Recovery Options on SQL server

Posted by Sagar Patil

Backup Types

There are 5 backup types. All these backups can be carried out online. databases. Offline backups require SQLSERVER be stopped. Offline backups are useful for the master, msdb and model databases

1. Full : This takes a complete copy of the database and logs.

2. Differential : This takes a copy of all changed pages since the last full backup (for database and logs.)

3. Transaction Log : This takes a copy of the transactions logs and clears its contents on completion.

4. File or File group : This copies only the specified file or group.

5. File differential : This takes a copy of all changed pages in file since the last file backup. In situations when the backup is too big for a backup window. Read more…

Using a Maintenance Plan to Backup SQL Databases

Posted by Sagar Patil

Maintenance Plans are only displayed to those users who are connected to the SQL Server using Windows Authentication Mode.

Read more…

SQL Server Transaction Log Shipping Replication

Posted by Sagar Patil

Prerequisite :

  • 2 separate SQL database instances at 2 different physical boxes – T-B0399254ED744 & TVLX4686.
  • A share accessible to Primary and Secondary Server for log shipping

Here I am going to log replicate AdventureWorks database from T-B0399254ED744 to TVLX4686

Read more…

Top of Page

Top menu