USE REPORTSERVER; SELECT COUNT(RE.REPORTID) AS EXECUTION_COUNT ,CAT.NAME ,CAT.PATH ,SUM(TIMEDATARETRIEVAL) / COUNT(NAME) AS AVG_MS_DATA_RETRIEVAL ,SUM(TIMEPROCESSING) / COUNT(NAME) AS AVG_MS_PROCESSING ,SUM(TIMERENDERING) / COUNT(NAME) AS AVG_MS_RENDERING ,SUM(BYTECOUNT) / COUNT(NAME) AS AVG_BYTE_COUNT ,SUM([ROWCOUNT]) / COUNT(NAME) AS AVG_ROW_COUNT ,CAST(MIN(TIMESTART) AS DATE) AS FIRST_RUN ,CAST(MAX(TIMESTART) AS DATE) AS LAST_RUN --,RE.USERNAME FROM CATALOG CAT LEFT JOIN ( SELECT EL.REPORTID ,EL.TIMESTART ,EL.TIMEDATARETRIEVAL ,EL.TIMEPROCESSING ,EL.TIMERENDERING ,EL.BYTECOUNT ,EL.[ROWCOUNT] --,EL.USERNAME FROM EXECUTIONLOG EL) AS RE ON CAT.ITEMID = RE.REPORTID WHERE CAT.TYPE = 2 GROUP BY RE.REPORTID ,CAT.NAME ,CAT.PATH --,RE.USERNAME ORDER BY NAME ,PATH; |
Practical Business Intelligence Solutions using the
Microsoft BI Suite of Tools provided along with Microsoft SQL Server
Monday, November 24, 2014
Reporting Metrics for SSRS
Here is a practical query that can be easily modified to provide SSRS Reporting Metrics and help find unused or misconfigured objects; Modify the granularity by simply uncommenting the UserName lines of code below.
Thursday, September 4, 2014
ERROR: User does not have required permissions. Verify that sufficient permissions have been granted and Windows User Account Control (UAC) restrictions have been addressed.
This happens when you are on the server and want to administer report content from the server. In short, the problem is that the local user does not have permissions. It appears to be a bug in the how permissions get set up within SSRS.
RESOLUTION
Run IE, Firefox or whatever as administrator
Navigate to http://localhost/Reports - (Do not use http://<server name>/Reports)
From the Root Folder, Click on "Folder Settings" as below
Click on New "Role Assignment" and add "Content Manager" to the person you want to administer your content
Labels:
reporting services,
SQL 2014,
ssrs,
uac,
USER ACCOUNT CONTROL
Friday, February 28, 2014
SSRS Divide by Zero Handling Alternative
So in creating an SSRS report recently which contained percent calculations in the totals I came across a divide by zero error I could not get around. All the checks for null/0 in the world wouldn't get rid using the expression editor.
Here is the formula for the detail level where it works fine:
Margin = (Price-Cost)/Price
and checking for zero values
Margin = Iif((Price-Post)=0 or Price=0),0, (Price-Cost)/Price
But for totals, it throws an error
Margin = (Sum(Price) - Sum(Cost))/Sum(Price)
Margin = Iif(((Sum(Price)-Sum(Cost))=0 or Price=0)),0, (sum(Price)-sum(Cost))/sum(Price)
SHOULD be straight forward,,,,, but not. It appears to be too complex in some way for the expression to be calculated and just returns errors.
So, and I'm borrowing here, I'm going to repost something simple but brilliant that was posted by William Mendoza on his blog site:
In the Menu; got to Report > Report Properties > Code and paste the code bellow
Public Function Quotient(ByVal numerator As Decimal, denominator As Decimal) As Decimal If denominator = 0 Then Return 0 Else Return numerator / denominator End If End Function
To call the function go to the the Textbox expresion and type:
=Code.Quotient(SUM(fields!FieldName.Value),SUM(Fields!FieldName2.Value))
in this case I am putting the formula at the Group level so I am using sum. Otherwise it would be:
=Code.Quotient(fields!FieldName.Value,Fields!FieldName2.Value)
Thanks William for your post and help
Here is the formula for the detail level where it works fine:
Margin = (Price-Cost)/Price
and checking for zero values
Margin = Iif((Price-Post)=0 or Price=0),0, (Price-Cost)/Price
But for totals, it throws an error
Margin = (Sum(Price) - Sum(Cost))/Sum(Price)
Margin = Iif(((Sum(Price)-Sum(Cost))=0 or Price=0)),0, (sum(Price)-sum(Cost))/sum(Price)
SHOULD be straight forward,,,,, but not. It appears to be too complex in some way for the expression to be calculated and just returns errors.
So, and I'm borrowing here, I'm going to repost something simple but brilliant that was posted by William Mendoza on his blog site:
In the Menu; got to Report > Report Properties > Code and paste the code bellow
Public Function Quotient(ByVal numerator As Decimal, denominator As Decimal) As Decimal If denominator = 0 Then Return 0 Else Return numerator / denominator End If End Function
To call the function go to the the Textbox expresion and type:
=Code.Quotient(SUM(fields!FieldName.Value),SUM(Fields!FieldName2.Value))
in this case I am putting the formula at the Group level so I am using sum. Otherwise it would be:
=Code.Quotient(fields!FieldName.Value,Fields!FieldName2.Value)
Thanks William for your post and help
Thursday, March 28, 2013
Remove Spaces and Non Alpahnumeric Characters
SELECTRTRIM(CUSTNMBR)AS CUSTNMBR
,REPLACE(REPLACE(CUSTNMBR ,SUBSTRING(CUSTNMBR ,PATINDEX('%[^a-zA-Z0-9 ]%' ,CUSTNMBR) ,1) ,'') ,CHAR(32) ,'')AS NU_CUSTNMBR
,CUSTNAME
FROM RECORDSTABLE
WHERECUSTNMBR LIKE '%[^a-zA-Z0-9 ]%'
OR CHARINDEX(CHAR(32) ,RTRIM(CUSTNMBR)) > 0;
,REPLACE(REPLACE(CUSTNMBR ,SUBSTRING(CUSTNMBR ,PATINDEX('%[^a-zA-Z0-9 ]%' ,CUSTNMBR) ,1) ,'') ,CHAR(32) ,'')AS NU_CUSTNMBR
,CUSTNAME
FROM RECORDSTABLE
WHERECUSTNMBR LIKE '%[^a-zA-Z0-9 ]%'
OR CHARINDEX(CHAR(32) ,RTRIM(CUSTNMBR)) > 0;
Friday, March 1, 2013
Excellent Query Analysis Tool
I'm always looking for new tools for SQL.
Here is one that truly sets the standard for Query Execution Plan Analysis:
SQL SENTRY PLAN EXPLORER
The feature I like about it this best is that you can navigate your sql code and the analysis plan window stays in sync with where you are in the code. Conversely, the code window is sync'd to the analysis plan.
On top of this, the tool also provides tabular performance metrics of the various operations instead of the user having to hunt through the diagrams to find the problems.
Best of all, there is a free version you can check out and decide if you want to get the reasonably priced pro-version.
There is too much in this tool for me to list all the great points about it. I realize this sounds like a sales pitch, but after you check it out you will be impressed too.
Here is one that truly sets the standard for Query Execution Plan Analysis:
SQL SENTRY PLAN EXPLORER
The feature I like about it this best is that you can navigate your sql code and the analysis plan window stays in sync with where you are in the code. Conversely, the code window is sync'd to the analysis plan.
On top of this, the tool also provides tabular performance metrics of the various operations instead of the user having to hunt through the diagrams to find the problems.
Best of all, there is a free version you can check out and decide if you want to get the reasonably priced pro-version.
There is too much in this tool for me to list all the great points about it. I realize this sounds like a sales pitch, but after you check it out you will be impressed too.
Friday, February 8, 2013
SMS Tips and Tricks SQL
I don't often link to other posts - Yeah I know, a fatal bloggers mistake. However, here is a a really nice set of tips:
http://www.bidn.com/blogs/MMilligan/bidn-blog/3326/sql-server-management-studio-ssms-tips-and-tricks
http://www.bidn.com/blogs/MMilligan/bidn-blog/3326/sql-server-management-studio-ssms-tips-and-tricks
Wednesday, January 23, 2013
Single Quotes in String Values
The following code includes an example of building a string value which has a single quote character in the text and also searching a field for a single quote character.
-- find the one record
declare @test varchar(1000)
declare @i int
IF OBJECT_ID('tempdb..#testtable') IS NOT NULL
DROP TABLE #testtable
create table #testtable
(val varchar(200)
)
-- Intentionally misspelled
set @i = 1
set @test = 'Had this been a real emergency, you''re keester would
already by fried'
while @i < 20
begin
insert
#testtable
select cast(@i as varchar(1000))
set @i = @i + 1
end
insert #testtable
select @test
select val
from #testtable
where val like '%''%'
Subscribe to:
Posts (Atom)