Skip to main content

Posts

Showing posts from 2014

Email Alerts are not received...

In one of application, Email alerts are sent using SQL sp_send_dbmail stored procedure. Email alerts were working properly, but suddenly noticed email alerts are not received.

To troubleshoot the issue, first I checked the msdb.dbo.sysmail_event_log table using the below query.

SELECT log_id, event_type, log_date, description, process_id, mailitem_id, account_id, last_mod_date, last_mod_user
FROM
msdb.dbo.sysmail_event_log 
ORDER BY
log_date DESC

If there is any error, you should see records with the event_type value as error.
In my case there are records with event_type value as error, and the description value for those records is same as below

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 3 (2018-02-01T10:41:27). Exception Message: Cannot send mails to mail server. (The SMTP server requires a secure connection or the client was not authenticated. The server response was: Authentication required).  )

As per the error descript…

Adding additional dimension attribute value in MDX query...

Depending on the requirements, sometimes it is necessary to do some categorizations which does not included in the dimension data. In such scenarios we may have to add a dimension attribute which currently does not exists with the dimension data.
We can do it in the MDX query as below.

WITH MEMBER [DimBranch].[Branch].[Dummy] AS '0', SOLVE_ORDER = 0 SELECT  {[Measures].[CONTRIBUTION USECASE]} ONCOLUMNS, NONEMPTYUnion( [DimBranch].[Branch].Members,    {[Branch].[Dummy]}) ONROWS FROM [Sales]


You can set the measure value based on the required logic.

Set the Visibility of a Dimension Hierarchy in SSAS...

In some scenarios, you may need to set the visibility of a dimension hierarchy as hidden. Because that hierarchy may be used for some of the calculation and it is not good to show that to the user.
In such a case, it can be done using the below steps.

Open the Cube available in the BIDS.Then select the Dimension Hierarchy available in the Cube Structure tab.Right click on it and select Properties.It will open the Properties window and set the Visible property value to False.Then deploy and process the Cube. When the cube is browsed, that dimension hierarchy will not be visible.

Passing Variable value from Parent package to a Child Package in SSIS 2012

If we are executing a package from another package, we may want to pass variable values from the parent package to the child package. In SSIS 2008, we get done this using the Parent Variable in the Package Configurations. But in SSIS 2012 the approach is different.

To achieve this we have to use the Package Parameters in the child package.
In this post I am using the Pkg_Main as the parent package and the Pkg_Sub as the child package. I want to pass the ParamValue_Parent  variable value in the Pkg_Main package to the Pkg_Sub package.

For that I used the below steps

Go to the Pkg_Sub package (child package) and create the ParamValue_Sub package parameter as shown in the below image.




Then create the ParamValue_Parent variable in the Pkg_Main package and set the value accordingly.


Then add the Execute Package Task to the Pkg_Main package Control Flow and select the Pkg_Sub package to execute.

To pass the ParamValue_Parent  variable value in the Pkg_Main package to the ParamValue_Sub par…

Importance of the Surrogate Key in Data Warehouse Design

In Data Warehousing, Surrogate Key is a unique identification key in a dimension table which is independent from the source.
Normally it is an auto increment integer value.

The purpose to have a surrogate key in a dimension table is to makes the relationship between dimension tables and fact tables independent from the source.
Below example will explain the importance of the surrogate key clearly.

Let's say in a company they maintains the employee code as a fixed digit number and assume the number of digit is 4.
After few years, the company is growing and the number of employees get increased.
Due to that 4 digit employee code will not be sufficient and they decided to makes the number of digits in the employee code to 6.
In such scenario, employee code of the every employee will get changed.

But in the data warehouse, if we use the employee code as the key without using any surrogate key, then the employee is linked with facts using employee code.
Therefore if the employee code …

Delete data using Partitions in SQL Server...

In a previous post I had explained how to partition SQL database tables. Actually we can use those partitions when we need to delete particular set of records from those large tables. Otherwise it will takes more time to delete those.
To create a stored procedure to truncate partition data, I reused a script in this link and applied some modification.
The added modifications are
Fixed the issue with joining the sys.partition_range_values for Right partitions Added the non-clustered index The below Stored Procedure uses to truncate partitions, created using the partition function from the previous post.
1:IFEXISTS (
2:SELECT *
3:FROM sys.objects
4:WHERE OBJECT_ID = OBJECT_ID(N'[SP_TruncatePartition]')
5:AND TYPE IN (N'P', N'PC')
6: )
7:DROPPROCEDURE [SP_TruncatePartition]
8:GO
9:
10:CREATEPROCEDURE [SP_TruncatePartition]
11: @tableName VARCHAR(255)
12: ,
13: @partitionValueString VARCHAR(8)
14: ,@partitionGranualirity VARCH…