Saturday, July 1, 2017

Thursday, June 15, 2017

Open SSRS Linked URLS in a new window I mentioned before sometimes I use my blog posts as a way to remind myself of the stuff that I need frequently and never keep to memory.

I needed to add a link in a new SSRS report and the link has to open in a new browser's window.

Just Right click on your report field, select "Text Box Properties", select "Action", click on the "FX" sign to write that special expression.

="javascript:void('" + Fields!URL.Value + "','_blank'))"

Assuming that your URL is dynamic and the column name is "URL" in your dataset

SSRS Link in  new Browser's Window
Hope that helps...

Tuesday, April 15, 2014

T-SQL Month Name,Number,Start and End of month


Today's requirement is to create a month's table, to be used in a SSRS report parameters, to be passed to a stored procedure.

the parameters needs to have Month Name, Number, Abbreviation, Start and End of month.

Please find the T-sql code below:

;WITH     months (MonthNumber)
AS       (SELECT 1
          UNION ALL
          SELECT MonthNumber + 1
          FROM   months
          WHERE  MonthNumber < 12)
SELECT   MonthNumber,
         DATENAME(month, DATEADD(month, MonthNumber, -1)) AS [MonthName],
         UPPER(LEFT(DATENAME(month, DATEADD(month, MonthNumber, -1)), 3)) AS MonthAbbr,
         DATEADD(month, DATEDIFF(month, 0, CONVERT (VARCHAR (2), MonthNumber) + '/1/' + CONVERT (VARCHAR (4), YEAR(GETDATE()))), 0) AS StartOfMonth,
         DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, CONVERT (VARCHAR (2), MonthNumber) + '/1/' + CONVERT (VARCHAR (4), YEAR(GETDATE()))) + 1, 0)) AS EndOfMonth
FROM     months
ORDER BY MonthNumber;  

Hope that helps..

Sunday, September 1, 2013

SSIS trim leading zero from a string

Today I was checking a question on one of the forums about trimming a leading zero from a string, and the string has characters, also has middle and ending zeros, so the methods that comes to your mind quickly won't work !!  If you're thinking about converting to INT then to a string again !

so I thought about a script component that uses the .NET (String.TrimStart Method) you can read about it more here :

here's the input scenarios that I came with and the output results....


1-I created a flat file (TXT) with punch of rows to test
2-Only one output from my flat file for simplicity, named Col0

3-script component (transformation Type), using Col0 as input.

4-created an output column Col0Cleaned

5-added the above highlighted line... and that's' it!


Please let me know if you have any scenarios that this solutions couldn't fix!
package and solution can be downloaded from here....

Hope that helps ......


SSRS Strip Domain from User!UserID

In SSRS, if you want to be fancy and display the USER NAME in the header or footer of your reports, like what I do.  SSRS uses Domain\UserName format... So someone this morning was asking in the forums about how to strip the domain out.

So I provided two solutions...

="Welcome " & MID(User!UserID,InStr(User!UserID,"\")+1, Len(User!UserID))

="Welcome " & =right(User!UserID, InStr(StrReverse(User!UserID),"\")-1)

Hope that helps someone...


Tuesday, April 30, 2013

SQL server date formats

Today, I've stumbled upon a nice resource of various SQL server date formats, and here I'm sharing it.

hope it helps when converting from one format to another !