I'm completely new to SSRS report subscriptions and I have 700+ ssrs report subscriptions. All the subscriptions were working till last month and now subscriptions will be in "Pending" state and after 2~3 hours of time all the subscriptions will execute and deliver to the user.
I have tried below ways but none these helped.
I have restarted the subscriptions manually in "SQL Server Agent".
Created a new subscription on my email ID but even new subscription also will be in pending state and after 2~3 hours it will trigger.
Restarted the "SQL Server Reporting Service" from Services.
Restarted the Server where this subscriptions are hosted.
Someone suggested to check the & character in "ExtensionSettings" column in Subscription table, but there is no & character.
Below queries i have tried but could not get anything.
SELECT s.[SubscriptionID] -- Subscription ID
,s.[OwnerID] -- Report Owner
,s.[Report_OID] -- Report ID
, c.Path -- Report Path
,rs.ScheduleID as SQLJobName -- Name of Job on SQL Server
,s.[Description] -- Description of the report subscription
,s.[LastStatus] -- Status of last subscription execution.
,s.[EventType] -- Subscription type
,s.[LastRunTime] -- Last time subscription executed
,s.[Parameters] -- Parameters used for subscription
,s.[DeliveryExtension] -- How to deliver the subscription
FROM [ReportServer].[dbo].[Subscriptions] as s
left join dbo.Catalog as c on c.ItemID = s.Report_OID
left join dbo.ReportSchedule as rs on rs.ReportID = s.Report_OID
order by c.Path
SELECT Top 10 * FROM dbo.ExecutionLog WHERE CAST(TimeStart AS DATE)
BETWEEN '21/10/2019' AND '21/10/2019' ORDER BY TimeStart DESC
Select * FROM dbo.ExecutionLog2 WHERE CAST(TimeStart AS DATE) BETWEEN
'7/1/2014' AND '7/2/2014' ORDER BY TimeStart DESC
SELECT Top 5000 * FROM dbo.ExecutionLog3 where Status <> 'rsSuccess' and
CAST (timestart as date) =cast('2019-10-24 10:00:29.120' as date) ORDER BY
TimeStart DESC
What could be the possible cause for pending state and delay in subscriptions? how to solve this issue?
Thanks in advance!
I found answer myself after analyzing deeply. In order to solve the issue i have followed two steps.
Step 1: I have removed/cleared all the subscriptions which are returning with error like "library!WindowsService_0!152c!09/09/2010-13:47:42:: e ERROR:".
Step 2: "DatabaseQueryTimeout" - Increased the limit (default is 120)
Related
I am using MS Access 2013.
The query I am working on is called "Bookings Query." Within the Bookings Query, I have two tables (Initialization and Bookings) joined together by Assignment Code. The Initialization table contains data for Sales Reps and their assignments with start/end dates and the Bookings table contains data for assignments and their monthly quota.
I need to have monthly quota data from the Bookings table only appear if it's within the Start and End Dates which come from the Initialization table. For Example: if we look at Assignment "ABC", and quota is $150,000 for January but the start and end dates for "ABC" are 2/1/21 - 12/31/21, then I need January to be $0 since quota for this assignment does not start until February.
Thanks in advance. It's a bit confusing I know.
Below is a sample I have used regularly
SELECT DISTINCTROW Accounts.AccountNumber, Accounts.AccountName, Sum(Transactions.[DEBIT AMOUNT]) AS DEBIT, Sum(Transactions.[CREDIT AMOUNT]) AS CREDIT
FROM Accounts LEFT JOIN Transactions ON Accounts.AccountID = Transactions.AccountID
WHERE (((Transactions.TransactionDate)>=[forms]![Report Date Range]![Beginning Rpt Date] And (Transactions.TransactionDate)<=[Forms]![Report Date Range]![Ending Rpt Date]))
I want to write a query to display jobs that are not yet expired. I also want to show the jobs that are expiring today.
SELECT jd.`job_title`,jd.`date_expiry`,jc.`category_title`
FROM `job_details` AS jd
JOIN `job_category` AS jc
ON jc.`category_id`=jd.`category_id`
WHERE jd.`company_id`=2
AND jd.`date_expiry` >= NOW()
ORDER BY jd.`date_expiry` ASC
The query works fine for jobs that are expired yesterday or before, but it does not show jobs that are expiring today. Jobs that are expiring today are supposed to be shown to users. Please help.
I think the problem with your query is that NOW() returns a timestamp at this exact moment in time, which could be in the middle of the day, the beginning, or the end. If NOW() were in the middle of the day, then anything expiring before that point would be excluded from your query. One workaround would be to compare to the current date at midnight.
You can use TIMESTAMP(CURRENT_DATE) to achieve this, and read here for a very helpful DBA Stack Exchange question.
SELECT
jd.job_title,
jd.date_expiry,
jc.category_title
FROM job_details AS jd
INNER JOIN job_category AS jc
ON jc.category_id = jd.category_id
WHERE jd.company_id = 2 AND
jd.date_expiry >= TIMESTAMP(CURRENT_DATE) -- compare to today at midnight
ORDER BY jd.date_expiry
I have the dataset in the image
105665 Status changed 03-2017, Decommissioned from the prior month of 02-2017, Pending Decommissioned.
On a monthly basis, I need to determine which Assets have changed Status from the "prior" month. I was thinking a new field is needed that tells me which Assets have changed status from the prior month but don't know how to determine that logic. I will also need a count of Assets of how many moved from Pending Decommissioned to Decommissioned for example or from Installed to Pending Decommissioned but I'll worry about that part later.enter image description here
(I have found similar cases but not exactly like this one so although I still tried those solutions, none of them worked for me).
Many thanks!
In your status table, you can join to the prior month, showing those rows that have a different value. Below assumes your dates are not text.
Select tm.asset
, tm.date
, lm.date
, tm.status
, lm.status
from table tm
inner join table lm
on tm.date = lm.date - INTERVAL 1 MONTH
and tm.asset = lm.asset
First time questioner so apologies for any vagueness or rule breaking
We use a ServiceDesk application that can produce a variety of pre configured reports and show the SQL query behind them.
I then take these reports and create a wallboard from a SQL Server Report Server to give some "live" management information.
The application records work logs with a time stamp that seems to reference the number of milliseconds since 1/1/1970. I can generate the SQL query from the application to filter for "this month" for example and it them puts the time stamp in to my report such as the one below
SELECT ad.ORG_NAME "Account",wo.WORKORDERID "Request ID",ct.DESCRIPTION
"Time Spent Description",ct.TIMESPENT "Time Spent",wtd.NAME "Worklog
Type",ct.TS_STARTTIME "Time Spent Starttime",rctd.FIRST_NAME "Time Spent
Technician",cd.CATEGORYNAME "Category",qd.QUEUENAME "Group",lvd.LEVELNAME
"Level"
FROM WorkOrder wo LEFT JOIN WorkOrderToCharge wotoc ON
wo.WORKORDERID=wotoc.WORKORDERID
LEFT JOIN ChargesTable ct ON wotoc.CHARGEID=ct.CHARGEID
LEFT JOIN SDUser rcti ON ct.TECHNICIANID=rcti.USERID
LEFT JOIN AaaUser rctd ON rcti.USERID=rctd.USER_ID
LEFT JOIN WorkLogTypeDefinition wtd ON ct.WORKLOGTYPEID=wtd.WORKLOGTYPEID
LEFT JOIN WorkOrder_Queue woq ON wo.WORKORDERID=woq.WORKORDERID
LEFT JOIN QueueDefinition qd ON Woq.QUEUEID=qd.QUEUEID
LEFT JOIN WorkOrderStates wos ON wo.WORKORDERID=wos.WORKORDERID
LEFT JOIN CategoryDefinition cd ON wos.CATEGORYID=cd.CATEGORYID
LEFT JOIN LevelDefinition lvd ON wos.LEVELID=lvd.LEVELID
INNER JOIN AccountSiteMapping asm ON wo.siteid=asm.siteid INNER JOIN
AccountDefinition ad ON asm.accountid=ad.org_id
WHERE (((ct.TS_STARTTIME >= 1441062000000) AND
((ct.TS_STARTTIME != 0) AND (ct.TS_STARTTIME IS NOT NULL))) AND
((ct.TS_STARTTIME <= 1443653999000) AND (((ct.TS_STARTTIME != 0) AND
(ct.TS_STARTTIME IS NOT NULL)) AND (ct.TS_STARTTIME != -1)))) AND
wo.ISPARENT='1'
The problem with this is that on the first of the month I have to go back to the servicedesk application - run the report again to update the tiem values to to reflect the current month - then transfer the query it generates over to the SSRS query. I would like to be able to remove the ct.ts.starttime elements of this query and instead have a filter in SSRS Dataset to only show the results where the ct.ts.startime is within the current month for example.
I am afraid I have very little SQL skills so if any one could point me in the right direction I would be very grateful
Thanks
BFG
You just need to change your WHERE clause to limit it within the current month using the starttime.
WHERE DATEADD(s, ct.TS_STARTTIME / 1000, '1970-01-01') BETWEEN CAST(DATEADD(D, 1 - DATEPART(d, GETDATE()), GETDATE()) AS DATE) AND CAST(DATEADD(m, 1, DATEADD(D, 1 - DATEPART(d, GETDATE()), GETDATE())) AS DATE)
AND ct.TS_STARTTIME IS NOT NULL AND wo.ISPARENT='1'
The only problem I see is that you don't say (and may not know) what version of SQL is being used (SQL Server, Oracle SQL, MySQL...). Unfortunately, most of these use a different function to get the current date. I used SQL Server's GETDATE() function.
I am trying to create SQL query that calculates the number of hours between two dates (2015-01-01 12:12:12). The complexity of this query is on sum up hours only between Monday to Friday from 8am to 6pm.
I need it to calculate how long it took for a issue logged in our Mantis BT system to be resolved. Our clients can log issues outside our working hours, but I only want to calculate hours based on our working hours.
We calculate the difference between the date/time when the issue was logged (submitted_date) to when the issue was resolved (maximum updated_date and "resolved" status). The difficulty is that an issue can be resolved, and then reopened in the future. By using the maximum updated_date, my script is including the days that the issue was in "resolved" status, which is not correct. It should only include days while issue is open.
SELECT
proj.name,
bugs.id,
summary,
users2.username AS Assigned_to,
CASE bugs.status
WHEN '80' THEN 'Resolved'
WHEN '90' THEN 'Closed'
END AS Status,
bugs.date_submitted AS date_submitted,
MAX(date_modified) AS last_date_modified
FROM
mantis_bug_table bugs
LEFT JOIN mantis_bugnote_table notes ON notes.bug_id = bugs.id
INNER JOIN mantis_bug_history_table hist ON bugs.id = hist.bug_id
LEFT JOIN mantis_user_table users2 ON users2.id = bugs.handler_id
INNER JOIN mantis_project_table proj ON proj.id = bugs.project_id
WHERE
bugs.project_id = 102
AND hist.field_name = 'status'
AND bugs.status IN (80,90)
AND date_modified >= '2015-01-01'
GROUP BY
summary;
This tutorial is written for SQL, but can be replicated easily in MySQL.
You just need to define your working hours, then reference these to calculate the time.