Thursday, February 17, 2011

Start and End Date of specific date.

Declare @Date datetime, @Start Datetime, @End Datetime

SET @Date = '02/17/2011' ------- Your Date

SET @Start = DATEADD(dd, 1, DATEADD(dd, -DATEPART(dd, @Date), @Date))
SET @End = DATEADD(dd, -1, DATEADD(mm, 1, @Start))

SELECT @Start AS [Start Date], @End  AS [End Date]

Tuesday, February 15, 2011

Date and Time dimension creation and population T-SQL

Just to point and give credit to this helpful script to create Date and Time dims in SSAS, I know that you can use the wizard in SSAS t ocreate and populate data in a date Dimension but not a time dimesion.

It's by Joshua A. Walker

The script is http://www.sqlservercentral.com/scripts/Data+Warehousing/65762/...

Monday, February 14, 2011

The end of my SSRS "NaN" misery! Avoid SSRS "NaN"....

I always had problems with that annoying “NaN” in SSRS, I used to run around it using IIF or REPLACE and ROUND, but finally I decided not to give up and find a neater solution for that particular report. 
Reading more about the IIF function @ http://msdn.microsoft.com/en-us/library/27ydhh0d%28vs.71%29.aspx
At the remarks section, they say “The expressions in the argument list can include function calls. As part of preparing the argument list for the call to IIf, the Visual Basic compiler calls every function in every expression. This means that you cannot rely on a particular function not being called if the other argument is selected by Expression.”
Anyway to cut my story short, if you have a function like:
=IIF(Lookup(Fields!ADM_DR_ID.Value, Fields!ADM_DR_ID.Value, Fields!ID2010.Value, "LOS") = nothing, "0" , Lookup(Fields!ADM_DR_ID.Value, Fields!ADM_DR_ID.Value, Fields!ID2010.Value, "LOS"))
It’s not going to work.
The right way is to avoid dividing by zero!
=IIF(Fields!ID2010.Value = 0, "0" , Lookup(Fields!ADM_DR_ID.Value, Fields!ADM_DR_ID.Value, Fields!ID2010.Value, "LOS"))
Hope that helps someone!

Sunday, January 30, 2011

System variables in SSIS

As part of my confirmation e-mail after a successful package run; I enclude some expressions in the body of the mail message.

2 or 3 of them are using the system variables that already comes out of the box in SSIS

Such as:

"Package Name: " + @[System::PackageName]   + "\n"+

"Was executed at:  " +  (DT_WSTR, 40) @[System::StartTime] + "\n" +

"Package Duration: " + (DT_STR, 6 , 1252) DateDiff ("ss", @[System::StartTime], GetDate())+ " Seconds"

Saturday, January 22, 2011

SSRS Templates in VS 2005 & 2008

The process is about creating a new template report, just an empty one, including the header photo and some of the built in fields.


then saveing the .RDL file at
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\ProjectItems\ReportProject\   
if you’re using VS 2005 
Or
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\ProjectItems\ReportProject\     
if you’re using VS 2008

Using the template:


I usualy save 2 templates, I call them "ComapnyName_Template_Landscape"  and "ComapnyName_Template_Portrait"

Download my sample .RDL template.

Thursday, December 30, 2010

SSAS: Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))

Today, I've no idea what happend to my SSAS suddenly!! but I got that nasty error while browsing one of my cubes.
Searched it down and found that you'll need to re-install the 'office 2003 web components' Although I'm using Office 2010 for the last 2 Months.
Also if you have time, please read that... will explain more Office Web Components “Roadmap”