Executing Stored procedure in SSRS - sql-server

I'm new to SSRS and I have a very simple question: I am executing a stored procedure in SSRS and generating some results. Does the SSRS keeps hitting the SP continuously in the backend even when the SQL Server Data tool is closed, as I am seeing SP's query execution in a DMV result.

SSRS calls the Stored Procedure only when instructed to when a report is run. If you request a new rendering of the report, the SP will be called again.
You need to ensure that there are no subscriptions for this report running, or other users commanding requests of the report that you are unaware of (users are logged in the ExecutionLog3 table).

SSRS only run stored procedure/query when we run our report after deployment, other then that no query or stored procedure executes at the back end by its on.
Other than that we have a concepts of subscription in SSRS, which allows us to subscribe SSRS report after a desired time interval (daily, monthly or any other criteria). In this case whenever our report runs after given time interval the corresponding query/stored procedure will be executed.

Related

Preventing Blank SSRS Reports from Emailing without Enterprise Edition (No Data-Driven Option)

I have been looking into this all day, and haven't found an answer that is either viable, or simple enough to implement.
I have several reports built in SSRS that I have emailed to myself on a daily basis. They run a stored proc that yields results, which are then sometimes filtered down more using visibility functions in the report, or are compared to other stored proc results.
What I am having trouble with is that sometimes, after all of the filters (either in Stored Proc, or after filtering by report), there is no data, and I get a 'blank' report with a header and nothing else. I am trying to eliminate these. However, I cannot do Data-Driven subscriptions because I don't have Enterprise edition of SQL Server. And nearly every answer I have found to prevent these blank reports involves doing that. Is there another way without Data Driven to do this? TIA!
Instead of the report triggering the Stored Procedure, you can have your stored procedure run on a schedule and then trigger your report subscription (if there are records).
You already have most of it done.
You just need to
END your subscription so it no longer runs automatically
Add logic to check for records for your report - DECLARE #CHECK AS INT = (SELECT COUNT(*) FROM <REPORT QUERY>)
Then IF #CHECK > 0, trigger your current subscription with:
EXEC dbo.AddEvent #EventType = 'TimedSubscription', #EventData = 'xxx';
replacing the xxx with your report subscriptions ID (found in the subscription link). The EXEC doesn't care that your subscription has an end date from step 1.
Then you just need to schedule your stored procedure to run on your schedule. You should have a JOB AGENT on your report server that you can utilize.

SQL Server Query Plan creation in SSMS vs Application Server

I have the following scenario:
After a database deployment we have a .Net application server that is attempting to execute a stored procedure.
The timeout on the application is 30 seconds. When the application first attempts to execute the stored proc an attempt is made to create a new query plan but this takes longer than 30 seconds and the application has many timeouts. My experience with this is that if the stored procedure is run manually(with representative data inputs) from SSMS the first time it runs it takes about 1-2 minutes, a plan gets generated and then the application then runs smoothly.
I work with a third party company and there is s DBA there who is claiming the following:
"Manually invoking this stored procedure will create a plan that is specific to the connection properties used (SSMS), the plan generated would not be used when the procedure is invoked by an application server."
Is this correct? It seems like a poor design if query plan used was linked to connection properties? Is there a difference between a query plan created if you run the stored procedure manually in SSMS vs when it is executed by an application?
If so, What is the optimal way to resolve this issue? Is increase the timeout the only option?

SSRS Parameters - Values from a query (parallelism)

I have SSRS report that has a single data source - SSAS Tabular cube.
The report has 15 parameters that gets their values from the queries (datasets).
When a user opens the report, each parameter is populated, but each query execution is serialized (confirmed by Profiler / Execution Log). Each execution takes up to 70ms. As a result, it takes 1,000-1,200 ms just to open a report.
Is there a way to populate the report parameters in parallel?
Note that
when the report is running (user clicks "View Report"), all charts datasets are being executed in parallel, so SSAS/SSRS is definitely able to execute the queries in parallel.
"Use single transaction when processing the queries" checkbox is not checked for the data source.
SSRS/SSAS versions: 2016, latest SP/CU, Ent & Dev
UPDATE:
if I change the data source to SQL Server, the issue persists, SSRS is not executing the queries (for Report Parameters) in parallel.
Could you double check whether the datasets were executed in parallel or not? By default, datasets in a report are executed in parallel no matter they are generated from a single data source or multiple data sources. In your scenario, since the datasets use the same data source, and the “Use single transaction when processing the queries” option is not checked for the data source, the datasets should execute in parallel.

sql query notification service issue

We are getting timeout issues on our databases. So I trurned on SQL Server Profiler and see SQLQueryNotificationService running every second with long duration. I checked the Service Broker and there are bunch of SQLQueryNotificationService queues created. I don't think we created any of these queues also there are bunch of stored procedures like these SqlQueryNotificationStoredProcedure-15c5b84b-42b0-4cfb-9707-9b1697f44127. Could you please let me know how to drop them? If I drop them is there any impact on the database? Please let me know. I appreciate any suggestions.
Do you have an ASP.Net web site running or another application that creates Sql Server Cache dependencies? It is Sql Server Service Broker queues, it executes that WAITFOR ... statement which waits for around one minute (60000 msecs), then executes again next second. Shouldn't normally cause problems, it shouldn't block or delay your "normal" queries or stored procedures.
However, I saw it causing issues for me once - one of the stored procedures, when executed from the same web application that established the cache dependency, did timeout (or rather came back in 120 secs which is not acceptable). Exactly the same stored procedure, executed under the same account with same parameters, but from Management Studio, ran fine without any issues. It was SQL Server 2005 SP4.
SQL Profiler showed that in the middle of execution of my stored procedure (and always after the same INSERT INTO ... statement), its execution was interrupted and instead of its statement there was that WAIT FOR .... from Sql Query Notification, completed in one minute, then another WAIT FOR... starting and again, completed in 59 secs - and only after that the Profiler showed me my stored procedure completed. With the duration of 119000, which is almost exactly two minutes.
It was if that query notifications were joining the transaction within my stored procedure.
What helped: recompiled the offending stored procedure. I simply changed its script, did ALTER statement with some minor syntax changes. No problems after that.

SSRS sql query runs slow

I have a long time issue keep popping up every time.
I create ssrs report with some select query. when i try to run the report it takes around 20sec to render.
i've checked the sql profiler and indeed the query run more than 20 sec.
when i copy the query to the management studio, it runs in 0 sec.
as written in earlier posts i've tried the walk around of declaring parameters in the query and setting their value with the ssrs params. sometime it works, currently it doesn't...
any other walk around?
Configure your report to run from the cache.
Caching is a copy of the last executed report. It is not a persisted copy, it has a lifetime (like caching for 30 minutes). It is stored on the temp database. You can have only one "instance" per report (if you have parameters, you will have one per combination of parameter)
you can do that on the execution tab of the report on report manager
Make the sql statement into a stored procedure and use the WITH RECOMPILE option in the sp.
E.g.
CREATE PROCEDURE dbo.spname #ParamName varchar(30)
**WITH RECOMPILE**
AS
This will help counteract the "parameter sniffing" during the procedure execution and help improve performance.

Resources