SQL Server security best practice

Security! This is the word comes in mind of every concerned person when it come...

Change the Collation Settings in MS SQL Server

This post will show you how to change the collation settings in MS SQL Server for specific database...

Resolve collation conflict

In this post I will show you how you can resolve collation conflict error...

Book: SQL Server 2008 High Availability

In this book I have tried to cover every single piece of information that might requires for installing and configuring SQL Server HA option like Clustering, Replication, Log Shipping and Database Mirroring...

Why to recompile Stored Procedure

Generally, we create views and stored procedures (proc here after) ...


Learn SQL Server 2008 from Microsoft

Since some times their is a discussion on what's new in SQL Server 2008, when the reference material will be available!! Here is an answer to this, Microsoft has introduce a course at its E-Learning, the course aims to educate IT Professional who has prior experience working with SQL Server. Microsoft has made learning SQL Server 2008 easy by offering e-learning course, the course is devided into three category:

Enterprise Data Plateform

Business Intellegence

Database Developement

more details on this course is available here, all you need to have is a Windows Live Account https://www.microsoftelearning.com/eLearning/offerDetail.aspx?offerPriceId=139087


Some Tips for Merge Replication

* SQLAgent service should run under same domain account, which has local admin privilege and “Log in as a service” permission. This requires on both the server. In case, if SQL Server is not part of any Domain. We can use the user account which has identical name and password at servers i.e. ReplUser on SRVA with password ReplUser! and identically ReplUser on SRVB with password ReplUser!
* User account that is used to run the SQLAgent services have to have sysadmin privilege on both server, and it should be added in to db_owner fixed db role for database which is being replicated/replicating.
* Should include all the tables which are referenced, this will help to keep data consistency.
* If there are text/image column we need to update those column explicitly Updatetext statement. http://msdn2.microsoft.com/en-us/library/aa260658(SQL.80).aspx
* Try to avoid using Identity column as PK but if it is already implemented modify the property of Identity column as ‘Not for Replication’.
* Define both server (Publisher and Subscriber) as remote server at each other.
* Allocate adequate space for distribution, subscription and publication db.
* Avoid using Identity column as PK but if it is already implemented modify the property of Identity column as ‘Not for Replication’.
* Rowguid column is must, which also can be added at the time of configuring Merge replication.
* sp_dropmergearticle can be used to drop article from publication.
* sp_addmergearticle can be used to add article to publication.
Below are some links that will be usefull for replication troubleshooting, they are:
Troubleshooting Merge Replication http://support.microsoft.com/kb/315521 and
Managing Identity values in Replication environment http://msdn2.microsoft.com/en-us/library/aa237098(SQL.80).aspx
Violation of Primary Key (PK) Constraint http://support.microsoft.com/kb/813494

Merge agent incorrectly deletes rows after PK violation error
Adding and Droping an article in existing publication http://msdn2.microsoft.com/en-us/library/ms152493.aspx
Working with BLOB data in Replciation http://technet.microsoft.com/en-us/library/ms151206.aspx


Estimating the size of Table

Many time it happens we were wrong with the Estimation of Table Size, wrong estimation of Row Size can trouble us with the growth of the database and ultimately we are ending up with the space crunch, and all this because of wrong Estimation of Table Size. So what we should consider the most with Estimating Table Sizing!!! Nullbitmap is the most important criteria here to take into consideration whenever you do a Estimation of Row Size, here is an excellent article on Row Size Estimation http://msdn2.microsoft.com/en-us/library/aa933068(SQL.80).aspx and http://msdn.microsoft.com/en-us/library/ms175991.aspx


Tuning Stored Procedure

Most of the time I come accross the thread wherein user has requested to get started with stored procedure performance tuning , so here are some good reference material for tuning stored procedure and optimize stored procedure for performance
http://www.sql-server-performance.com/tips/stored_procedures_p1.aspx, http://www.sqlservercentral.com/articles/Performance+Tuning+and+Scaling/performancetuningstoredprocedures/2505/ and http://searchsqlserver.techtarget.com/generic/0,295582,sid87_gci1247499,00.html


Automate Profiler Trace

The question I recently come accorss on SQL Server Performance, the OP was asking on "How to automate profiler trace" , their are system stroed procedure that can be used to automate profiler trace. The system stored procedure you can use are sp_trace_create,sp_trace_generateevent,sp_trace_setevent,sp_trace_setfilter and sp_trace_setstatus. Here is complete procedure described on "How to automate profiler trace" , refer http://vyaskn.tripod.com/server_side_tracing_in_sql_server.htm

Here is a link on "How to monitor trace on SQL Server 2005" http://support.microsoft.com/kb/912914/en-us


New KB articles are added for SQL Server 2005

New Knowledge Base articles are added for SQL Server 2005, Here are the links

FIX: The performance of a query that performs an insert operation or an update operation is much slower in SQL Server 2005 SP2 than in earlier versions of SQL Server 2005

FIX: You receive an incorrect result when you use a SQL Native Client provider to read the data on the client computer in SQL Server 2005

How to enable the SQL Server 2005 Integration Services process to generate a dump file when the process experiences exceptions

FIX: Error message when you run a query that selects many columns and that joins many tables in SQL Server 2005 Service Pack 2: "The query processor could not produce a query plan"

FIX: An application that is included in SQL Server 2005 may stop responding when you specify a network protocol that is not valid in the application

FIX: Error message when you use Database Engine Tuning Advisor to tune a database in SQL Server 2005 Service Pack 2: "An unhandled win32 exception occurred in dtaengine90.exe [4308]"

FIX: Error message when you use the Bcp.exe utility together with the queryout option in Microsoft SQL Server 2005: “BCP host-files must contain at least one column”

Some or all SQL Server 2005 services are not listed in SQL Server Configuration Manager, or you receive a "No SQL Server 2005 components were found" error message when you perform operations in SQL Server 2005 Surface Area Configuration

Error message when you run a distributed query against a loopback linked server in SQL Server 2005: "Transaction context in use by another session" or "MS DTC has cancelled the distributed transaction"

You cannot upgrade the named instance of SQL Server 2000 Desktop Engine Service Pack 3a that is installed together with Application Center 2000 Service Pack 2 to SQL Server 2000 SP4

Renaming SQL Server that hosts Reporting Server

Sometimes business demands or change in naming convention for servers lead to situation where one should change / rename the Server running MS SQL Server, it would not that panic renaming SQL Server as you have sp_dropserver and sp_addserver to help you, but what if this SQL Server box have reporting server too; well microsoft has workaround for it refer - http://technet.microsoft.com/en-us/library/ms345235.aspx


Devcon2007 - A great Success

Hi All,

I am too glad... DevCon 2007 organized pune has great success, over 1100 attendes was recorded for this event. I thought this would the highest number of audiance till date , it includs IT professionals and students.
Special thanks to all energetic members and volunteers of Pune User Group members and MSP(s) who has played key role in this success.



DevCon - 2007 Organized by Pune User Group

Pune User Group has organized an event “DevCon “ in the month of August, the details and for Entry passes check your nearest location on website



Download System View Map for MS SQL Server 2005

Download the System View map for SQL Server 2005, this would definately helpfull to DBA(s).

Webcast on Reading Execution Plan and Query Tuning


Aug - 28th ; 14:00 - 15:30 IST

SQL Server 2005: Reading Execution Plans
The toughest part of analysis of any query is reading the execution plans. Many see this as the most difficult part, but this webcast removes this myth. We will walk you through the various operators and what they mean in the actual reading of the execution plan. There are some small changes made between SQL Server 2000 to SQL Server 2005 and we will take a quick at the same too.

Speaker: Vinod Kumar

Aug - 28th ; 14:00 - 15:30 IST

SQL Server 2005: Query Tuning
As part of application development everyone is faced with the need to tune their applications query. One aspect will be reading execution plans, but there are tons of other parameters that need attention to start the tuning exercise. This webcast takes a look at those parameters and the various tools and the tuning parameters we need to use with SQL Server 2005.

Speaker: Vinod Kumar


hotfix or SP stops unexpectedly on SQL Server 2005

SQL Server 2005 Cluster which has many instances or contain many nodes may gives you error while upgrading it with hotfix or service pack; the simple procedure to update hotfix and sp has been given by Microsoft, read more on KB 936488

Failed to connecto to SSIS

Sometimes we receive "SSMS failed to connect to SSIS on client machine", Microsoft has released KB 940232 for the workaround

Timeout occured while running dbcc freeproccache/alter database/sp_configure/sp_detace_db

Some of us might have face timeout when we run DBCC FREEPROCCACHE, Alter Database, Restore Database, SP_configure or sp_detach_db ; Microsoft has released KB 925419 which has workaround for the problem.


Disaster Recovery Articles on MS SQL Server

Here are some good Disaster Recovery articles on MS SQL Server


TechMela 2007 is here!

TechMela 2007 is a first of its kind technology Mela in India. Erstwhile we had TechEd for developers, ITPC for IT Pros, IndiMix for designers and MEDC for Mobile and Embedded Professionals. Each of these events used to happen at few chosen cities. Now with this new event, it will be one place for 4 days! details at www.techmela.com

read more | digg story


Feature Pack for SQL Server 2005

Have you downloaded stand alone value addition packages for SQL Server 2005 like Best Practice Analyzer,Performance Dashboard etc. ? Here is a link where you can find this all http://www.microsoft.com/downloads/details.aspx?familyid=50b97994-8453-4998-8226-fa42ec403d17&displaylang=en


Dear All MVP(s),
SQLSPEC is a software that helps DBA(s) to document Database Objects, It is a tool from
Elsasoft LLC; they are giving out SQLSPEC for free to MVP(s) and significant contributors to SQL Server Community, drop a mail to sqlspec@elsasoft.org, with below information
Your full name
Proof of your contribution to the database community
Proof of your Microsoft MVP, Microsoft MCT, or Oracle ACE status if applicable

There's more detail here: http://www.elsasoft.org/mvp.htm
You may also have a look at Software Spotlight at http://www.sql-server-performance.com/software_spotlights/da_sqlspec.asp


What is a Log Shipping?

High Availability is a hot topic today and need for a business critical applications, as a DBA we always try to cope up with such situation where High Availability and Continuity comes into picture their are technologies that you can use for; Log Shipping is one of them.
Have you ever had a chance to set up Log Shipping? What are the benefits of using Log Shipping over Clustering or Replication? How ever it *depends* upon your environment and requirement at given time. Refer below link for Log Shipping...

Log Shipping Article


What is Log Shipping?

What is Log Shipping?
Log Shipping is one of the solutions for High Availability for business critical application. Log Shipping is first introduced in SQL Server 7.0. Log Shipping; as name defines does the shipping of Transaction Log to another server; it does exact replica of the database; it does backup of Transaction Log and restores it on a Secondary /Stand by Server which keeps database on secondary server in sync with the database on Primary Server. In case of failure work loss happens only for the time being copy of T-Log backup and restoring back to Secondary/Stand by Server. Stand by / Secondary server which can act as a primary server in case of failure. SQL Server DBA has to perform some manual tasks to bring it online for business.

Why to do Log Shipping?
There are other options like Clustering and Replication for High Availability of Business Critical Application, so why do we go for Log Shipping?
Well, there are reasons for choosing Log Shipping against Cluster and Replications:

  1. Setting up: It is very easy to create a Log Shipping, only thing you need to identify is you must have two servers with SQL Server Enterprise Edition and a database(s) which is critical to your business environment.

  2. Manageability: It is easy to manage Log Shipping comparing to Replication and Cluster Server, generally Log Shipping works well and you don't feel panic with its monitoring or maintenance work.

  3. Act as a Reporting Server: Stand by or Secondary Server can act as a Reporting Server in your organization, your database which is being log shipped can be used for Read Only queries or I would rather say it can act as a Reporting Server. The thing need to be consider here is it will be unavailable at the time of Restoration of Transaction Log e.g. if your Transaction Log backup takes 10 minutes of Restoration Time and you does Log Shipping every 60 minutes then your Reporting/Secondary/Stand by Server will be un-available for 10 minutes.

  4. Can use multiple database(s)/server(s): You can use multiple server(s) as a Stand by or Secondary Server for different purpose, e.g. you can create two Stand by server(s) one for Reporting and another for High Availability

  5. Cheaper then cluster: If you go for a Cluster Server you will have to meet software and Hardware requirement; I mean you need identical hardware to setup clustering where as in case of Log Shipping you don't need to have exactly the same set of hardware for Primary and Secondary or Stand by server.

  6. Best solution for physical dispersed location: Data Center: In your environment you are having a cluster server configured at your Data Center for high availability so that if in case of any failure or damaged you can recover your data back, imagine what if your data center itself got damaged!!!!!! In this type of scenario Log Shipping does good job you can configure Log Shipping to Dr Server which is at different physically location and if your local Data Center / Server got damaged you may still recover your data.
    You can do this thing using Replication too; in case of replication again you have to select Snapshot/Transactional/Snapshot Replication, now as you may use Log Shipping you would rather go for Snapshot Replication, you have to monitoring it regularly whether it is running or not!!! Where as with Log Shipping it generally runs smoothly and even if it caught an error it will tell you exact where it breaks so fixing a Log Shipping is not difficult.

How to do Log Shipping?

Here, I've tried describing Prerequisites and steps for setting up Log Shipping.


  1. Database must be in Full or Bulk-Logged Recovery Model.
    It is required that Database has to be in Full or Bulk-Logged Recovery Model,
    One can perform T-Log backup only when Database Recovery Model is set to Full or Bulk-Logged, here is a brief on recovery model.

Recovery Model Benefit Work Loss Type of Recovery 
Simple Keeps T-Log in small size, can perform bulk copy operation If needed you have to restore Full backup or Differential backup  Can done up to the last backup time 
Bulk-Logged Minimal log space occupation, can perform bulk operationIf the log is damaged or bulk operation is done after last T-Log backup Can done up to the last backup time 
Full No work lost due to damaged data file, Point-In-Time recoveryNormally none, only if you lost your most recent T-Log backupPoint-In-Time 

  1. Windows Account used to setup Log Shipping must have SQL Server System Admin rights on both servers.
    It will not break Log Shipping if you the password of Account has changed, because it needs to change at the same time on both the servers else Log Shipping will fails.

  2. Create a share on Primary Server and Secondary Server with change and write permissions for Windows Account User which is used for SQL Server Agent.

  3. You may Restore Full Database on Secondary Server manually or it can be done via Log Shipping installation itself at the time of setup process (Ensure this database on Secondary Server must be restored with NORECOVERY or STANDBY option).
    It is required to Restore Database with NORECOVERT | STANDBY because if the database restored in recovered/write enabled mode you can not apply another T-Log.

Optional Component : Monitoring / Witness Server 

Identify your Monitor Server which will look after for your Primary Server and Secondary Server's Activity.
It is better to use separate server which monitors the activity of Primary and Secondary Server so that you can get the alert even if server itself won't works.

Primary Server 

  1. Create a Share with read/write permission for domain user which we'll be using to startup SQLServerAgent

  1. Create a Full Database backup for

  2. Backed up T-Log on the folder you have created earlier to store the log backup
    You can create a maintenance plan to take a T-Log backup for regular interval and then add it as a Step in job to automate this process

  1. Please ensure that the duration must enough to copy the log backup file to Secondary Server.
    Suppose we are taking T-Log backup each 1/2 hour and if the backup file is big enough which takes more then 1/2 to copy over the network share, it will again creates a new T-Log backup which will then occupies recourse unnecessarily.

  2. Copy T-Log backup file to Secondary Server's shared folder

  3. Delete the T-Log backup file after it copied to the Secondary Server's shared folder.

  1. Ensure you have selected Allow Database to assume primary role option so that if in future requirement of role reversal can be possible easily.
    If in case we need to change the role of primary server or secondary server to act as Primary or Secondary this option should be used while setting up Log Shipping.

  2. Ensure that you have set up proper threshold values for Destination Database for Out of Sync, Load Time Delay, File Retention Period and History Retention Period option.
    These options are self explanatory: Out of Sync=used by witness server to send alert if the specified time has been exceeded between Last T-Log backup on primary and secondary server, Load Time Delay= Destination Database waits before it restores the T-Log, File Retention Period= Time elapse till file gets deleted and History Retention Period= Time till we retain History details

Secondary Server 

  1. Check if the Database is already exists on Secondary Server, if it is already their drop it.

  1. Restore a Full Database Backup for LogShDB

  1. Restore a T-Log for LogShDB on the secondary server which is copied on the shared folder of Secondary Server;

  1. Ensure you have given STANDBY or NORECOVERY option while restoring T-Log backup for LogShDB.

You may find log shipping is a very use full yet simple to configure, use and manage, it is cheaper and easily manageable solution for High Availability of your data. It is a good solution over clustering (because it is costly; requires identical hardware to setup cluster) and easily manageable, easy troubleshooting against replication as it clearly says where it breaks. Generally Log Shipping works very smooth once it is configured. Even if you have to re-configure it from the scratch it is easy job to do.



Logging and Data Storage Algorithms in MS SQL Server

Ever wonder how SQL Server Logs data in T-Log and Data Files? What algorithm it uses!!! What is ARIES (Algorithm for Recovery and Isolation Exploiting Semantics), refer Microsoft Knowledge Base Article http://support.microsoft.com/kb/230785 which gives the complete details how it works!! With the detail explanation on each steps and terms.


Do Win a Lottery - Money from Microsoft

Now a days I have seen too many emails in my inbox fwd by friends and unknown persons claiming that THEY WON $$$$$ BECAUSE THEY FWD THIS TO THIS MANY PEOPLE, SOME ARE ASKING FOR ADVANCE MONEY TO GET YOU MORE MONEY and this type of emails are fake / fraud emails don't ever forward them and do not believe in this kind of emails. This is now confirmed by Microsoft Officials so ignore this type of emails and don't ever believe on it. Refer below link for more


Hemantgiri S. Goswami


Download free Database Tools

At times we need to analyze the Size of the Database, or have to search the Object or Content in the Database, we always query system tables or create a script for self and some times we uses sp_depends,Query Analyzer and EM or SSMS but it has some limitations.

To reduce this effort we often try some third party softwares and we know that they comes at cost. Mohamed Bouarroudj of  SQLDBTOOL has 3 software to help us out and yes they are FREE!!! There are 3 tools he has developed SQLDBDiff, SQLDBSearch and SQLDBSize.

1. SQLDBDiff:  compares the schema and the data of SQL Server databases. SQLDBDiff supports SQL Server 2008, 2005 and 2000. Download SQLDBDiff from here 

2. SQLDBSearch:  find any object by its name or content in one or many SQL Server databases. SQLDBSearch supports SQL Server 2005 and 2000. Download SQLDBSearch from here

3. SQLDBSize: display size used or reserved by tables, indexes, databases, transaction logs and physical files graphically. Download SQLDBSize from here


Index Defregment Best Practice

Here is the best article on Index Defregment Best Practice published on Microsoft Web Site


Hemantgiri S. Goswami

Microsoft SQL Server MVP

Technorati Tags: , , ,

powered by performancing firefox


Place where I Live


Difference between Stored Procedure and Function (UDF)


  • can be used with Select statement

  • Not returning output parameter but returns Table variables

  • You can join UDF

  • Can not be used to change server configuration

  • Can not be used with XML FOR clause

  • Can not have transaction within function

Stored Procedure

  • have to use EXEC or EXECUTE

  • return output parameter

  • can create table but won’t return Table Variables

  • you can not join SP

  • can be used to change server configuration

  • can be used with XML FOR Clause

  • can have transaction within SP

New Version Microsoft SQL Server 2005 SP2 and Books On Line release

New version of SQL Server 2005 SP2 & SQL Server 2005 Books Online (BOL) released and now available at http://www.microsoft.com/sql/sp2.mspx


Disappearance of Jim Gray

If you are participating in community activity regularly you must aware of Jim Gray a great guy, he is disappear near Farallon Islands: Help searching Jim Gray, a known Database Guru


Remote Deployement of SQL Server

Hi All,

When it comes to deploying a SQL Server Remotely with Sharepoint service, we just think and search around to get the answer how do i?!!!

Here is a very good article on the Remote Deployment of SQL Server with Sharepoint Services, Refer http://www.microsoft.com/resources/documentation/wss/2/all/adminguide/en-us/stsc02.mspx?mfr=true for more.

Hemantgiri S. Goswami
Microsoft SQL Server MVP
"Humans don't have Caliber to PASS TIME , Time it self Pass or Fail Humans"

Disclaimer: This postings is provided "AS IS"


SQL Server : TO Blob or Not

Hi All,

In many community forums i participated i found many users ask a querstion on BLOB datatype. That is "Is it okay if i do store binary files / images / documents store in SQL Server Database?" . The answer is no.....it is always good to store the location of the Binary Files or Documents Or Images and let it handled by Front End application. Here is a wonderfull research paper published on Microsoft Site http://research.microsoft.com/research/pubs/view.aspx?msr_tr_id=MSR-TR-2006-45

Hemantgiri S. Goswami
Microsoft SQL Server MVP
"Humans don't have Caliber to PASS TIME , Time it self Pass or Fail Humans"

Disclaimer: This postings is provided "AS IS"

New Year Gift from Microsoft

Hi All,
I am honored Microsoft Most Valuable Professional in Windows Server System - SQL Server Competency for year 2007. A wonderfull gift from Microsoft.

Hemantgiri S. Goswami

"Katmai" - Next Version of SQL Server

Hi All,
Microsoft officials has announced in their blog at ZDNET website, They code name it "Katmai" that would be next version of Microsoft SQL Server and that's not just a SQL Server but more then that. Read more on it http://blogs.zdnet.com/microsoft/?p=217

Hemantgiri S. Goswami
Microsoft SQL Server MVP
"Humans don't have Caliber to PASS TIME , Time it self Pass or Fail Humans"

Disclaimer: This postings is provided "AS IS"



This post confirms my ownership of the site and that this site adheres to Google AdSense
program policies and Terms and Conditions

-- Hemantgiri S. Goswami