Wednesday 18 January 2012

SQL SERVER – Union vs. Union All – Which is better for performance?

This article is completely re-written with better example SQL SERVER – Difference Between Union vs. Union All – Optimal Performance Comparison. I suggest all of my readers to go here for update article.

UNION

The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type. With UNION, only distinct values are selected.

UNION ALL

The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values.

The difference between Union and Union all is that Union all will not eliminate duplicate rows, instead it just pulls all rows from all tables fitting your query specifics and combines them into a table.

A UNION statement effectively does a SELECT DISTINCT on the results set. If you know that all the records returned are unique from your union, use UNION ALL instead, it gives faster results.

Example:

Table 1 : First,Second,Third,Fourth,Fifth
Table 2 : First,Second,Fifth,Sixth

Result Set:

UNION: First,Second,Third,Fourth,Fifth,Sixth (This will remove duplicate values)
UNION ALL: First,First,Second,Second,Third,Fourth,Fifth,Fifth,Sixth,Sixth (This will repeat values)

Wednesday 4 January 2012

DTSBackup 2000


DTSBackup 2000 is a designed to help with both backup and transfer of DTS packages. Whilst it is not recommended as a substitute for your normal file and database backup routines, it is an additional layer of protection, with the benefit of package level granularity. See the article Backing Up Packages for additional information.

http://www.sqldts.com/272.aspx

Whilst the name is backup, it is most frequently recommend as a tool to transfer packages between servers, either directly or via a file stage.
This version of DTSBackup provides full support for Microsoft SQL Server 2000. New features introduced in this version of DTSBackup include a new DTSBackup file format and direct transfer of packages between SQL Servers. These methods do not suffer the loss of layout information encountered when using the DTS object model.
Limited support for password protected packages is also included as well as more detailed progress information and errors encountered during a transfer.
There are now two individual executables, one for manual transfer with the improved user interface, and a separate command line executable which can be installed on its own.
Full documentation is provided, so to find out more download it and give it a try.
Please mail any feature requests and bug reports here.
Remove the tinned meat decoy from the email address before sending.


Error while opening SSIS package


When we open up existing SSIS project, we always get this error.  

TITLE: Microsoft Visual Studio
------------------------------

Unable to cast COM object of type 'Microsoft.SqlServer.Dts.Runtime.Wrapper.PackageNeutralClass' to interface type 'Microsoft.SqlServer.Dts.Runtime.IObjectWithSite'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{FC4801A3-2BA9-11CF-A229-00AA003D7352}' failed due to the following error: The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD)).


Resolution : 



To fix the problem do the following:
1.       Open the command prompt
2.       Navigate to C:\Program Files\Microsoft SQL Server\90\DTS\Binn
3.       Run C:\Program Files\Microsoft SQL Server\90\DTS\Binn>regsvr32 dts.dll
That should fix the problem.