SSRS Navigation Options - reporting-services

I am looking to enhance the web interface of my SSRS instance (2016). Are there any options to use tabs or a left hand report hierarchical tree to navigate between the reports?
Currently all I can see is the ability to go up a level then be presented with a list of the reports available in that level.
Are there any other options or generally accepted solutions for better navigation within SSRS?
One thing that caught my eye was document maps. Is there a way to create a document map which enables report navigation? Not navigation within a report, but navigation to another report?
Thanks
Mike

I use a report to view all the deployed reports on the report server. It could get you part of the way there. The icons are links to folders/reports. I also show the execution count and subscription count. The XML code exceeds the limit in this answer. Here's a shortcut to the XML/rdl file in GitHub. Copy and paste the XML into a text file then rename the text file with .rdl extension.
Screenshot of report preview
SQL for the report
/*
+-----------------------------------------------------------------------------
| Purpose: To search deployed reports on the report server
| Note: SQLCmdMode Script (from the SSMS menu [Query]|[SQLCMD Mode])
+-----------------------------------------------------------------------------
:setvar _server "YourServerNameHere"
:setvar _database "ReportServer"
--:setvar _user "***username***"
--:setvar _password "***password***"
--:connect $(_server) -U $(_user) -P $(_password)
:connect $(_server)
USE [$(_database)];
GO
DECLARE #ReportFolder AS VARCHAR(100)
DECLARE #ReportName AS VARCHAR(100)
DECLARE #ReportDescription AS VARCHAR(50)
DECLARE #CreatedBy AS VARCHAR(50)
DECLARE #CreatedDate AS DATETIME
DECLARE #ModifiedBy AS VARCHAR(50)
DECLARE #ModifiedDate AS DATETIME
DECLARE #ReportDefinition AS VARCHAR(50)
DECLARE #SearchFor AS VARCHAR(50)
DECLARE #SearchType AS VARCHAR(50)
DECLARE #all_value AS VARCHAR(50)
SET #ReportFolder = '<ALL>'
SET #ReportName = NULL
SET #ReportDescription = NULL
SET #CreatedBy = NULL
SET #CreatedDate = NULL
SET #ModifiedBy = NULL
SET #ModifiedDate = NULL
SET #ReportDefinition = NULL
SET #SearchFor = NULL
SET #SearchType = NULL
SET #all_value = '<ALL>'
*/
;WITH
report_users
AS
(
SELECT [UserID], [SimpleUserName] = UPPER(RIGHT([UserName], (LEN([UserName])-CHARINDEX('\', [UserName])))) FROM dbo.[Users]
)
,
report_catalog
AS
(
SELECT
rpt.[ItemID]
, rpt.[CreatedById]
, rpt.[ModifiedById]
, rpt.[Type]
, rpt.[Name]
, rpt.[Description]
, rpt.Parameter
, [CreationDate] = CONVERT(DATETIME, CONVERT(VARCHAR(11), rpt.[CreationDate], 13))
, [ModifiedDate] = CONVERT(DATETIME, CONVERT(VARCHAR(11), rpt.[ModifiedDate], 13))
, [ReportFolder] = SUBSTRING(rpt.[Path], 2, Len(rpt.[Path])-Len(rpt.[Name])-2)
, rpt.[Path]
, [URL_ReportFolder] = 'http://' + Host_Name() + '/Reports/browse/' + SUBSTRING(rpt.[Path], 2, Len(rpt.[Path])-Len(rpt.[Name])-2)
, [URL_Report] = 'http://' + Host_Name() + '/Reports/report/' + SUBSTRING(rpt.[Path], 2, Len(rpt.[Path])-Len(rpt.[Name])-2) + '%2f' + rpt.[Name]
, [ReportDefinition] = CONVERT(VARCHAR(MAX), CONVERT(VARBINARY(MAX), rpt.[Content]))
FROM
dbo.[Catalog] AS rpt
WHERE
1=1
AND rpt.[Type] = 2
)
SELECT
rpt.ItemID
, rpt.[Name]
, rpt.[Description]
, rpt.[Parameter]
, [ReportCreatedBy] = urc.[SimpleUserName]
, [ReportCreationDate] = rpt.[CreationDate]
, [ReportModifiedBy] = urm.[SimpleUserName]
, [ReportModifiedDate] = rpt.[ModifiedDate]
, rpt.[ReportFolder]
, [ReportPath] = rpt.[Path]
, rpt.[URL_ReportFolder]
, rpt.[URL_Report]
, rpt.[ReportDefinition]
, [CommandText] = rpt.[ReportDefinition]
, el.[ExecutionLogCount]
, sc.[SubscriptionCount]
, [SearchForStr] = ISNULL(#SearchFor, ' ')
FROM
report_catalog AS rpt
LEFT JOIN (SELECT [ExecutionLogCount] = COUNT([ReportID]), [ReportID] FROM dbo.[ExecutionLog] GROUP BY [ReportID]) el ON el.[ReportID] = rpt.[ItemID]
LEFT JOIN (SELECT [SubscriptionCount] = COUNT([Report_OID]), [Report_OID] FROM dbo.[Subscriptions] GROUP BY [Report_OID]) sc ON sc.[Report_OID] = rpt.[ItemID]
LEFT JOIN report_users AS urc ON rpt.[CreatedById] = urc.[UserID]
LEFT JOIN report_users AS urm ON rpt.[ModifiedById] = urm.[UserID]
WHERE
1=1
AND (#all_value IN (#ReportFolder) OR rpt.[ReportFolder] IN(#ReportFolder))
AND (#CreatedBy IS NULL OR urc.[SimpleUserName] LIKE '%' + #CreatedBy + '%')
AND (#CreatedDate IS NULL OR rpt.[CreationDate] >= #CreatedDate)
AND (#ModifiedBy IS NULL OR urm.[SimpleUserName] LIKE '%' + #ModifiedBy + '%')
AND (#ModifiedDate IS NULL OR rpt.[ModifiedDate] >= #ModifiedDate)
AND (
#SearchFor IS NULL
OR (
(rpt.[Name] LIKE '%' + #SearchFor + '%' AND (#all_value IN(#SearchType) OR 'Report Name' IN(#SearchType)))
OR (rpt.[Description] LIKE '%' + #SearchFor + '%' AND (#all_value IN(#SearchType) OR 'Report Description' IN(#SearchType)) )
OR (PATINDEX('%' + #SearchFor + '%', rpt.[ReportDefinition]) > 0 AND (#all_value IN(#SearchType) OR 'Report Definition' IN(#SearchType)) )
)
)

Related

How to check if data is present in mysql xamp and if data is not present,how can i insert data in sql and if data is there houw can i update the data?

Here, this my my code that i tried in trigger
SELECT store_name FROM all_store_individual IF(store_name!=NEW.store_name )
THEN
INSERT INTO all_store_individual (NULL,NEW.store_name,NEW.qty,NEW.product_cost,NEW.sale_price_shipping,NEW.cogs,NEW.gross_profit,NEW.amazon_fee,NEW.supplier_tax,NEW.supplier_shipping_cost,NEW.amazon_administrative,NEW NEW.net_profit,NEW.befrugal,NEW.cash_back_profit,NEW.total_profit,NEW.amazon_tax)
ELSE
UPDATE all_store_individual SET product_cost = product_cost + NEW.product_cost, qty = qty + NEW.qty, sale_price_shipping=sale_price_shipping+NEW.sale_price_shipping, cogs = cogs + NEW.cogs , gross_profit = gross_profit + NEW.gross_profit , amazon_fee = amazon_fee +NEW.amazon_fee , supplier_tax = supplier_tax +NEW.supplier_tax , supplier_shipping_cost = supplier_shipping_cost + NEW.supplier_shipping_cost , amazon_administrative = amazon_administrative+NEW.amazon_administrative , net_profit = net_profit + NEW.net_profit , befrugal = befrugal + NEW.befrugal , cash_back_profit =cash_back_profit + NEW.cash_back_profit WHERE store = NEW.store_name;

Exporting database permissions to a CSV file

I am trying to export all the user information / permissions to a file for documentation. I trying to find a script out this task, is there anyway to pull all the permission from all the SQL databases from a server at one time? Working with SQL 2008 and 2012.
#Damaged I used powershell to export "Database-Level Object Permissions".. you can try below soluition.
[string]$SrvIns = 'YourServerName'
[string]$db = 'YourDatabaseName'
$sql = " SELECT
usr.name AS 'User',
CASE WHEN perm.state <> 'W' THEN perm.state_desc ELSE 'GRANT' END AS PermType,
perm.permission_name,
USER_NAME(obj.schema_id) AS SchemaName,
obj.name AS ObjectName,
CASE obj.Type
WHEN 'U' THEN 'Table'
WHEN 'V' THEN 'View'
WHEN 'P' THEN 'Stored Proc'
WHEN 'FN' THEN 'Function'
ELSE obj.Type END AS ObjectType,
CASE WHEN cl.column_id IS NULL THEN '--' ELSE cl.name END AS ColumnName,
CASE WHEN perm.state = 'W' THEN 'X' ELSE '--' END AS IsGrantOption
FROM
sys.database_permissions AS perm
INNER JOIN sys.objects AS obj
ON perm.major_id = obj.[object_id]
INNER JOIN sys.database_principals AS usr
ON perm.grantee_principal_id = usr.principal_id
LEFT JOIN sys.columns AS cl
ON cl.column_id = perm.minor_id AND cl.[object_id] = perm.major_id
WHERE
obj.Type <> 'S'
ORDER BY
usr.name, perm.state_desc ASC, perm.permission_name ASC"
Invoke-Sqlcmd -ServerInstance $SrvIns -Database $db -Query $sql | Export-Csv C:\permission.csv
Good Luck**
Here is a script that someone found for me it works perfect. I'm posting so other people can use.
set nocount on
declare #permission table (
Database_Name sysname,
User_Role_Name sysname,
Account_Type nvarchar(60),
Action_Type nvarchar(128),
Permission nvarchar(60),
ObjectName sysname null,
Object_Type nvarchar(60)
)
declare #dbs table (dbname sysname)
declare #Next sysname
insert into #dbs
select name from sys.databases order by name
select top 1 #Next = dbname from #dbs
while (##rowcount<>0)
begin
insert into #permission
exec('use [' + #Next + ']
declare #objects table (obj_id int, obj_type char(2))
insert into #objects
select id, xtype from master.sys.sysobjects
insert into #objects
select object_id, type from sys.objects
SELECT ''' + #Next + ''', a.name as ''User or Role Name'', a.type_desc as ''Account Type'',
d.permission_name as ''Type of Permission'', d.state_desc as ''State of Permission'',
OBJECT_SCHEMA_NAME(d.major_id) + ''.'' + object_name(d.major_id) as ''Object Name'',
case e.obj_type
when ''AF'' then ''Aggregate function (CLR)''
when ''C'' then ''CHECK constraint''
when ''D'' then ''DEFAULT (constraint or stand-alone)''
when ''F'' then ''FOREIGN KEY constraint''
when ''PK'' then ''PRIMARY KEY constraint''
when ''P'' then ''SQL stored procedure''
when ''PC'' then ''Assembly (CLR) stored procedure''
when ''FN'' then ''SQL scalar function''
when ''FS'' then ''Assembly (CLR) scalar function''
when ''FT'' then ''Assembly (CLR) table-valued function''
when ''R'' then ''Rule (old-style, stand-alone)''
when ''RF'' then ''Replication-filter-procedure''
when ''S'' then ''System base table''
when ''SN'' then ''Synonym''
when ''SQ'' then ''Service queue''
when ''TA'' then ''Assembly (CLR) DML trigger''
when ''TR'' then ''SQL DML trigger''
when ''IF'' then ''SQL inline table-valued function''
when ''TF'' then ''SQL table-valued-function''
when ''U'' then ''Table (user-defined)''
when ''UQ'' then ''UNIQUE constraint''
when ''V'' then ''View''
when ''X'' then ''Extended stored procedure''
when ''IT'' then ''Internal table''
end as ''Object Type''
FROM [' + #Next + '].sys.database_principals a
left join [' + #Next + '].sys.database_permissions d on a.principal_id = d.grantee_principal_id
left join #objects e on d.major_id = e.obj_id
order by a.name, d.class_desc')
delete #dbs where dbname = #Next
select top 1 #Next = dbname from #dbs
end
set nocount off
select ##SERVERNAME as Server_name,* from #permission

SQL CASE in SELECT clause

I need to add a concatenated field to my SELECT clause based on the results of my WHERE clause. Here is my current query:
Declare
#Low numeric(13,0) = 10000,
#High numeric(13,0) = 100000000000,
#Name varchar(100) = '%',
#Stname varchar(100) = '%georgia',
#Sumlev varchar(3) = 1,
#County varchar(30) = 123456,
#Place varchar (5) = 8,
#Gid2 varchar(5),
#Gid2_1 varchar (7);
if object_id('tempdb..#GeoID2') is not null drop table #GeoID2
SELECT
SUMLEV, State, County, Place, Name, Stname, ESTIMATESBASE2010, CONCAT(REPLICATE('0', 2 - LEN(STATE)) + STATE, REPLICATE('0', 3 - LEN(COUNTY)) + COUNTY) AS Gid2
INTO
#GeoID2
FROM
[CensusData].[dbo].[SUB-EST2014_ALL]
WHERE
(NOT (SUMLEV = #Sumlev)) AND (NOT (County = #County)) AND (NOT (PLACE = #Place)) AND
(ESTIMATESBASE2010 > #Low) AND (ESTIMATESBASE2010 < #High) AND (Name LIKE #Name) and (Stname LIKE #Stname)
SELECT
[#GeoID2].SUMLEV, [#GeoID2].State, [#GeoID2].County, [#GeoID2].Place, [#GeoID2].Stname, [#GeoID2].Name, [#GeoID2].ESTIMATESBASE2010, [ACS_14_5YR_S1901_with_ann].[HC01_EST_VC13] as Avg_Salary, [#GeoID2].Gid2, [#GeoID2].Gid21
FROM
[CensusData].[dbo].[#GeoID2] INNER JOIN
[CensusData].[dbo].[ACS_14_5YR_S1901_with_ann] ON [CensusData].[dbo].[#GeoID2].Gid2 = [CensusData].[dbo].[ACS_14_5YR_S1901_with_ann].[GEO id2]
ORDER BY
[#GeoID2].NAME
I need to add a CASE statement to my first SELECT clause to assign a value to Gid2. The current value is assigned as:
CONCAT(REPLICATE('0', 2 - LEN(STATE)) + STATE, REPLICATE('0', 3 - LEN(COUNTY)) + COUNTY) AS Gid2
What I need to do is check the value of [County] before I assign this value. Based on that result I will use one of two formulas. Here is what I tried (that does not work):
Case
When (County = 0)
Then 'CONCAT(REPLICATE('0', 2 - LEN(STATE)) + STATE, REPLICATE('0', 5 - LEN(PLACE)) + PLACE) AS Gid2'
Else 'CONCAT(REPLICATE('0', 2 - LEN(STATE)) + STATE, REPLICATE('0', 3 - LEN(COUNTY)) + COUNTY) AS Gid2'
End
I am not sure that using CASE is the right way to go, but I can't figure out any other way to approach this. Can someone help?
Ok I figured it out. I was using ' in front of my Concat function when I should have been using (. Here is a working query:
Declare
#Low numeric(13,0) = 10000,
#High numeric(13,0) = 100000000000,
#Name varchar(100) = '%',
#Stname varchar(100) = '%georgia',
#Sumlev varchar(3) = 1,
#County varchar(30) = 123456,
#Place varchar (5) = 8,
#Gid2 varchar(5),
#Gid2_1 varchar (7);
if object_id('tempdb..#GeoID2') is not null drop table #GeoID2
SELECT
SUMLEV, State, County, Place, Name, Stname, ESTIMATESBASE2010,
Case
When (County = 0)
Then (CONCAT(REPLICATE('0', 2 - LEN(STATE)) + STATE, REPLICATE('0', 5 - LEN(PLACE)) + PLACE))
Else (CONCAT(REPLICATE('0', 2 - LEN(STATE)) + STATE, REPLICATE('0', 3 - LEN(COUNTY)) + COUNTY))
End AS Gid2
INTO
#GeoID2
FROM
[CensusData].[dbo].[SUB-EST2014_ALL]
WHERE
(NOT (SUMLEV = #Sumlev)) AND (NOT (County = #County)) AND (NOT (PLACE = #Place)) AND
(ESTIMATESBASE2010 > #Low) AND (ESTIMATESBASE2010 < #High) AND (Name LIKE #Name) and (Stname LIKE #Stname)
SELECT
[#GeoID2].SUMLEV, [#GeoID2].State, [#GeoID2].County, [#GeoID2].Place, [#GeoID2].Stname, [#GeoID2].Name, [#GeoID2].ESTIMATESBASE2010, [ACS_14_5YR_S1901_with_ann].[HC01_EST_VC13] as Avg_Salary, [#GeoID2].Gid2
FROM
[CensusData].[dbo].[#GeoID2] INNER JOIN
[CensusData].[dbo].[ACS_14_5YR_S1901_with_ann] ON [CensusData].[dbo].[#GeoID2].Gid2 = [CensusData].[dbo].[ACS_14_5YR_S1901_with_ann].[GEO id2]
ORDER BY
[#GeoID2].NAME

How to create multiple HTML tables of data inside 1 email

I am trying to send 2 different tables inside of 1 email. I want one table to establish data concerning data stored in 1 database and the other table for a second database of information. I can produce 1 email simply enough but i cannot understand how to set a second table with a completely different query and data in the same email.
here is what i am currently working with:
USE MY DATABASE
DECLARE
#tableHTML NVARCHAR(MAX)
SET #tableHTML =
N'<H1>Lacrosse Inquiries</H1>' +
N'<table border="1" style="text-align: middle;" width:100% height:20px style="cell" cellspacing="0" cellpadding="5">' +
N'<tr><th>FIRST NAME</th><th>LAST NAME</th><th>Entry Term</th></th><th>Market Segment</th><th>State</th><th>Home Number</th><th>Cell Phone</th>'+
CAST ( ( SELECT td = INQUIRY.F_NAME , ''
, td = INQUIRY.L_NAME , ''
, td = INQUIRY.ENTRY_TERM , ''
, td = INQUIRY.MARKET_SEG , ''
, td = EWADDRESS.STATE , ''
, td = EWADDRESS.HOME_PHONE , ''
, td = EWADDRESS.WORK_PHONE , ''
from EWSTUDENT AS INQUIRY inner join EWMULTI1M as sport on sport.EWSTUID=INQUIRY.EWSTUID left JOIN EWADDRESS ON EWADDRESS.EWSTUID=INQUIRY.EWSTUID LEFT JOIN ESTUDENT ON ESTUDENT.EWSTUID=INQUIRY.EWSTUID
where VCODETYPE = 'EACTIV1M' AND VCODE ='CLAX' AND INQUIRY.GENDER = 'F' AND STUD_TYPE ='P' and (CONVERT(VARCHAR(8), sport.CREATE_DT, 112) = CONVERT(varchar(8), GETDATE(), 112))
order by INQUIRY.L_NAME
FOR XML PATH('tr'), TYPE
) AS NVARCHAR(MAX) ) +
N'</table>' ;
EXEC msdb.dbo.sp_send_dbmail
#profile_name= 'Jordan.Sorensen',
#recipients = 'Jordan.sorensen#svu.edu',
#from_address = 'Jordan.Sorensen#svu.edu',
#body = #tableHTML,
#execute_query_database= 'MY DATABASE',
#subject ='Womens Lacrosse Inquiries',
#body_format= 'HTML'
GO
ANY SUGGESTIONS ON HOW TO CREATE TWO DIFFERENT TABLES WITH TWO COMPLETELY DIFFERENT SETS OF DATA IN ONE EMAIL?
FOR XML PATH('tr'), TYPE
) AS NVARCHAR(MAX) ) +
N'</table>' --<-- This is where you 1st query ends add a couple of line breaks
+ N'<br/><br/>' -- and add you second table just like you have done before
+ N'<table border="1" style="text-align: middle;" width:100% height:20px style="cell" cellspacing="0" cellpadding="5">'
+ N'<tr><th>FIRST NAME</th><th>LAST NAME</th><th>Entry Term</th></th><th>Market Segment</th><th>State</th><th>Home Number</th><th>Cell Phone</th>'
+ CAST ( (/*Your Select just like you have done for 1st table*/) AS NVARCHAR(MAX))
+ N'</table>'
Obviously HTML generated from both sql queries are concatenated and set the value to variable #tableHTML, the rest of the stuff remains the same passing parameters to your procedure and etc etc.

Dynamically create filename in SSRS 2008

I have been asked a couple times to change the file name dynamically in SSRS 2008. Example: ReportName_201101.RDL. The 201101 represents the execution date. Can this be accomplished in SSRS 2008?
If you mean the filename when you export the report and also happen to be pulling it from the ASP.NET ReportViewer, you can set the name through the DisplayName property.
ReportViewerControl.ServerReport.DisplayName = "ReportName_201101";
or (if ProcessingMode is Local):
ReportViewerControl.LocalReport.DisplayName = "ReportName_201101";
For pretty much all other cases, Alison is right.
There is an MS Connect item open for this. It only has a few votes, so head over there and upvote it...
Another work around, is to rename the report before it runs automatically. This is a diamond in the rough. This may only work for reports that are subscriptions and not ones that users link back to.
Create a table on the ReportServer database that contains a listing of all reports that you want to rename before they execute.
Table Report_Rename_Listing
RenameID int
ItemID uniqueidentifier
OriginalReportName nvarchar(350)
DateType nvarchar(75)
Format int
DatePlusMinus real
Create a stored procedure on the same server that goes out and changes all the reports in the above table.
Create Procedure [dbo].[RenameReports]
AS
SET NOCOUNT OFF ;
Update dbo.Catalog
Set Name = ISNULL(( Select OriginalReportName + '_' +
dbo.func_SetupRenameOfReports(DateType, Format, DatePlusMinus)
From dbo.DDC_Report_Rename r
Where r.ItemID = c.ItemID), Name)
From dbo.Catalog c
return (0)
Create a scalar function on same server that figures out just how you want to rename the report.
Create Function [dbo].[func_SetupRenameOfReports]
( #DateType nvarchar(75), #Format int, #PlusMinus real )
RETURNS nvarchar(75)
AS
BEGIN
Declare #FirstMonth datetime, #LastMonth datetime
Declare #OutputFormat nvarchar(75)
Set #FirstMonth = CONVERT(datetime, Convert(varchar(2), DateAdd(mm, #PlusMinus, GetDate()), 103) + '/1/' + CONVERT(varchar(4), DateAdd(mm, #PlusMinus, GetDate()), 102))
Set #LastMonth = DATEADD(dd, -1, DateAdd(mm, 1, #FirstMonth))
Set #OutputFormat =
Case When #DateType = 'CurrentDate' Then Convert(varchar(75), DateAdd(dd, #PlusMinus, GetDate()), #Format)
When #DateType = 'CurrentDayName' Then CONVERT(varchar(75), DateName(dw, DateAdd(dd, #PlusMinus, GetDate())))
When #DateType = 'CurrentMonthName' Then CONVERT(varchar(75), DateName(mm, DateAdd(mm, #PlusMinus, GetDate())))
When #DateType = 'CurrentYear' Then CONVERT(varchar(75), DateAdd(yy, #PlusMinus, GetDate()))
When #DateType = 'CurrentBeginEndMonth' Then CONVERT(varchar(10), #FirstMonth, #Format) + '-' + CONVERT(varchar(10), #LastMonth, #Format)
End
If #OutputFormat IS null
Begin
Set #OutputFormat = ''
End
Return #OutputFormat
END
Then setup this up to have the stored procedure automatically run daily on your server. I have it run just after midnight every day.
Unfortunately, no, it is not possible. It is another one of those features that is missing from SSRS that developers have been asking for.
Here is a correction to the above stored procedure so that it actual works.
ALTER PROCEDURE [dbo].[ddc_RenameReports]
AS
SET NOCOUNT OFF ;
Update dbo.Catalog
Set Name = ISNULL((Select OriginalReportName + '_' +
dbo.func_SetupRenameOfReports(DateType, Format, DatePlusMinus)
From dbo.DDC_Report_Rename r
Where r.ItemID = c.ItemID And r.Active = 1), Name)
From dbo.Catalog c
Update c
Set c.Path = ISNULL((Select c2.Path + '/' + OriginalReportName + '_' +
dbo.func_SetupRenameOfReports(DateType, Format, DatePlusMinus)
From dbo.DDC_Report_Rename r2
Where r2.ItemID = c.ItemID AND r2.Active = 1), c.Path)
From dbo.Catalog c
inner join dbo.Catalog c2 on c2.ItemID = c.ParentID
return (0)