Archive

Author Archive

SSIS package to Remove Duplicates from any Database

January 19th, 2010 Arun Mallick No comments


Here comes one more challenging yet interesting topic to tide over. The requirement goes something like this: You have some sources, let it be some sales data or some Call center data coming from different sources. Data can be of different media. But you are able to load it in your staging tables i.e. one staging database you are maintaining like StageDB for storing these incremental data.

So, here we have both master i.e. Dimensional data and Detail i.e. Fact data in our stage database. But before processing further and loading it into our Mart or Data warehouse, we need to check if there is any redundancy at the row level for each of these tables in the staging database. Here comes the main problem, what if you don’t know how many tables are there in the staging database and how many columns are there for each table in the staging database but still you have to keep only unique records for each table.

Read more…

Categories: SSIS

ROLLUP with CURSOR for grouping

January 3rd, 2010 Arun Mallick No comments


Problem: I have a table for customer information with Customer Ids and Customer Type. The customer may fall into different types i.e. the customer may belong to Type A or Type B or may belong to both the groups. The requirement is to find out the count of the customers as per the type in each group and if the customer falls under more than one group, it must not be counted under the individual group rather it should be counted under the group with both the types.

Read more…

Categories: T - SQL

Top N Random records from each group

October 12th, 2009 Arun Mallick No comments


Problem:

The requirement is to get top 10 employee’s name randomly from each department in a company. Let me elaborate it. Suppose in a company ABC, there are 1500 employees with 5 departments and each department have more than 200 employees. The manager wants to list down at least 10 names of the employees randomly from each department for a survey.

Solution:

Read more…

Categories: Tips N Tricks

Database Summary

October 6th, 2009 Arun Mallick No comments
Categories: Tips N Tricks

Total number of days in a month

July 26th, 2009 Arun Mallick 2 comments


Here are some ways described to find out the total no. of days in a given month.

Read more…

Categories: T - SQL, Tips N Tricks

Last business day of any given month

July 25th, 2009 Arun Mallick No comments
Categories: T - SQL, Tips N Tricks

SQL Driver Issues Resolver

July 20th, 2009 Arun Mallick No comments

Driver Issues Resolver - Thumnail

Here comes the real deal, sometimes you may face some unexpected things happening in SQL Server while creating SSIS package or dealing with the same, like missing Foreach File Enumerator or Foreach Item Enumerator in Foreach loop container. You might be thinking that, maybe it is not available in my piece of software.

Read more…

Categories: Products

SQL Server Indexes – Pros and Cons (Part 3)

July 13th, 2009 Arun Mallick No comments

SQL Server Indexes – Pros and Cons (Part 2)

Optimizing Indexes in SQL Server: Although there are many bright faces of indexes but every coin have two sides. So it’s always advisable to implement indexes wisely on a table. Here we will check out different perspectives to view indexes on a given table.

Read more…

Categories: T - SQL

SQL Server Indexes – Pros and Cons (Part 2)

July 12th, 2009 Arun Mallick No comments

SQL Server Indexes – Pros and Cons (Part 1)

Types of indexes: We have basically two types of indexes in SQL Server.

  • Clustered index:  It’s a type of index where the data itself is arranged at the indexed column i.e. we have the actual data at the leaf nodes. For example, in a science definition pocket book, every word is arranged alphabetically and the definition of the word is given along with it. Here there is no need to look up for the referencing page, as in case of other example like in a general book with indexes at the end of the book, contains page number along with the term or word which is then followed to get the information about the term.

Read more…

Categories: T - SQL

SQL Server Indexes – Pros and Cons (Part 1)

July 11th, 2009 Arun Mallick No comments


Indexing has become a critical buzzword in the arena of databases. Not only database users, but also all of us are using indexes in our daily life.  Got puzzled? Let me give you one scenario. Have you ever noticed how did a librarian arranges and orders all the books in the library? And when you are asking for a particular book, he immediately gives it to you within some couple of minutes without searching the whole library. This is possible because he has already indexed each book and categorized them according to the author and the publisher and again ordered all the books falling under same author and publisher in an alphabetical order of the title. So when you ask for a particular book, he just refers to the shelf belonging to the author and publisher of the book and the book is with you in no time.

Read more…

Categories: T - SQL