SSRS subcription creation date? - reporting-services

There seems no created date in subscriptions table in reportserver database .
is there any way we can find out when a subscription was created?
Thank you

Here is one way to do it
select c.name,s.date_created, * from ReportSchedule rs
JOIN msdb.dbo.sysjobs s ON s.name = convert(varchar(max),rs.ScheduleID)
JOIN ReportServer.dbo.Subscriptions sb
ON rs.SubscriptionID = sb.SubscriptionID
JOIN ReportServer.dbo.Catalog c
ON sb.report_oid = c.itemid
ORDER BY s.date_created desc
s.date_created is the creation date

Related

How to query SSRS data driven subscription detail

I would like to retrieve SSRS data-driven subscription detail from the ReportServer DB. I am able to retrieve most of the detail from the table Subscriptions but I need the dataset information (SQL Query itself) which is used for Data-driven subscriptions.
Can I achieve that?
I was wondering the same thing recently and did some research + guessing. It's a complicated query but I believe this is what you're looking for. It will only show reports that ran in the last 30 days so you'll want to adjust it if you want everything.
The key here is the Subscriptions.DataSettings which is the field that contains the query you'll be looking for.
SELECT s.SubscriptionID, c.Name
, c.Type
,s.EventType
, c.Description
, u.UserName AS CreatedBy
, c.CreationDate
, c.ModifiedDate
, s.Description AS Subscription
, s.DeliveryExtension AS SubscriptionDelivery
, d.Name AS DataSource
, s.LastStatus
, s.LastRunTime
, s.Parameters
, sch.StartDate AS ScheduleStarted
, sch.LastRunTime AS LastSubRun
, sch.NextRunTime
, c.Path
,s.DataSettings
FROM Catalog c
INNER JOIN
Subscriptions s ON c.ItemID = s.Report_OID
INNER JOIN
DataSource d ON c.ItemID = d.ItemID
LEFT OUTER JOIN
Users u ON u.UserID = c.CreatedByID
LEFT OUTER JOIN
ReportSchedule rs ON c.ItemID = rs.ReportID
LEFT OUTER JOIN
Schedule sch ON rs.ScheduleID = sch.ScheduleID
WHERE (c.Type = 2)
and s.DataSettings is not null
and s.LastRunTime > getdate()-31
ORDER BY c.Name

SQL-Statement: Calendar event related to contact

I am in the process of developing an SQL query to let HeidiSQL display the calendar entries and connected contacts.
The appointments are included in the vtiger_activity table and the contacts in the vtiger_contactdetails table. A connection exists through the table "vtiger_crmentity".
SELECT a.subject
, a.activitytype
, a.date_start
, a.due_date
, a.time_start
, a.time_end
, d.firstname
, d.lastname
FROM vtiger_activity a
LEFT
JOIN vtiger_crmentity c
ON c.crmid = a.activityid
LEFT
JOIN vtiger_contactdetails d
ON d.contactid = c.crmid
WHERE a.due_date >= '2019-05-18' AND a.date_start <= '2019-05-23'
Result of Query: it shows the dates in the time period but in the columns where it should show the contact is everywhere only NULL The query I need it for a Android App. I expected firstname and lastname, because the data exists.
Does anyone know where I have my mistake?
Ever thank you for your help
Your LEFT JOINs are in the wrong order. If you want the names, they are from the details table, and that should be the first table in the FROM. You will also need to move the conditions to the ON.
Something like this:
SELECT d.firstname, d.lastname, a.subject, a.activitytype
a.date_start, a.due_date, a.time_start, a.time_end
FROM vtiger_contactdetails d LEFT JOIN
vtiger_crmentity c
ON d.contactid = c.crmid LEFT JOIN
vtiger_activity a
ON c.crmid = a.activityid AND
a.due_date >= '2019-05-18' AND
a.date_start <= '2019-05-23';

converting mysql sql to sql server

I have a MySQL SQL that works fine with Jaspersoft report:
SELECT pr.id AS project_id,
pr.project_name as project_name,
pr.export_event_id,
au.full_name,
ee.timestamp
FROM (
SELECT project.id, project.project_name, MAX(project.export_event_id) AS max_export_event_id FROM project INNER JOIN export_event iee ON project.export_event_id = iee.id
where IIF ($P{exportEventDate} IS NULL, TRUE, CONVERT(DATE, iee.timestamp) <= $P{exportEventDate})
GROUP BY project_name
) AS in_PR INNER JOIN project AS pr ON pr.project_name = in_PR.project_name AND pr.export_event_id = in_PR.max_export_event_id
INNER JOIN project_owner_base pob ON pob.id = pr.project_owner_id
INNER JOIN export_event AS ee ON pr.export_event_id = ee.id
INNER JOIN auth_user au ON pob.auth_user_id = au.id
WHERE IIF ($P{projectOwner} IS NULL, TRUE, au.id = $P{projectOwner})
I am trying to convert it to SQL Server but can't figure out the equivalent.
Think of the $P{...} as '?' in dynamic SQL
Any idea?
I think this is just a simple OR statement.
Where #ProjectOwner IS NULL
OR au.id = #ProjectOwner
Your query is pretty close. I would remove the IIF() entirely -- in either database. The result is something like this:
SELECT pr.id AS project_id,
pr.project_name as project_name,
pr.export_event_id,
au.full_name,
ee.timestamp
FROM (SELECT p.project_name, MAX(p.export_event_id) AS max_export_event_id
FROM project p INNER JOIN
export_event iee
ON p.export_event_id = iee.id
WHERE ? IS NULL OR CONVERT(DATE, iee.timestamp) <= ?
GROUP BY p.project_name
) in_PR INNER JOIN
project pr
ON pr.project_name = in_PR.project_name AND
pr.export_event_id = in_PR.max_export_event_id INNER JOIN
project_owner_base pob
ON pob.id = pr.project_owner_id INNER JOIN
export_event ee
ON pr.export_event_id = ee.id INNER JOIN
auth_user au
ON pob.auth_user_id = au.id
WHERE ? IS NULL OR au.id = ?;
I replaced the variables with ? (as suggested by your question). The above should work in either database.
Note that this also fixes the aggregation in the subquery to remove p.id which seems unnecessary (and should cause an error in SQL Server).

How to get monthly postcount of phpBB users with SQL query?

I'm new to this SQL stuff, working with phpmyadmin. I already managed to get all usernames but don't know how to get postcount and especially postcounts within a defined periode of time (month). This is what i got so far:
SELECT DISTINCT
ug.`user_id`,
u.`username`,
pfd.`pf_full_name`
FROM
`phpbb3_user_group` AS ug
INNER JOIN
`phpbb3_groups` AS g ON g.group_name = 'User'
INNER JOIN
`phpbb3_users` AS u ON u.`user_id` = ug.`user_id`
INNER JOIN
`phpbb3_profile_fields_data` AS pfd ON pfd.`user_id` = ug.`user_id`
WHERE
ug.`group_id` = g.`group_id` AND u.`user_type` = 0
ORDER BY
ug.`user_id`
SELECT user_id FROM phpbb_users u WHERE u.user_type IN (0, 3, 1) AND u.user_regdate > 1648771200 AND (u.user_lastvisit > 0 AND u.user_lastvisit < 1651276800) ORDER BY u.user_regdate ASC
April add user sql

Three table query MySQL

I have three tables that have common affiliate_id field:
impressions, clicks, commissions
I want to select all the data from these three tables where the affiliate_id = '$iAid' in one query, then handle the data in php.
How would I write a query like this?
Here's PHP code assuming you're using MYSQL:
$qry = "SELECT im.*, cl.*, co.*
FROM `impressions` im, `clicks` cl, `comissions` co
WHERE im.`affiliate_id`=cl.`affiliate_id`
AND cl.`affiliate_id`=co.`affiliate_id`
AND im.`affiliate_id`='".$iAid."'";
SELECT <YOUR COLUMN LIST>
FROM impressions a, clicks b, commissions c
WHERE a.affiliate_id = '$iAID'
AND a.affiliate_id = b.affiliate_id
AND b.affiliate_id = c.affiliate_id
SELECT * FROM impressions AS i JOIN clicks AS c ON i.affiliate_id = c.affiliate_id JOIN commissions AS m ON i.affiliate_id = m.affiliate_id WHERE i.affiliate_id = '$iAid'
should do the trick
Do a left join in mysql query:
Select * from Impressions imp
Left join clicks c on c.affiliate_id = imp.affiliate_id
Left join commissions com on com.affiliate_id = imp_affiliate_id
Where ***
limit ***
ect....
select * from
impression a
join clicks b on (a.affiliate_id = b.affiliate_id)
join commissions c on (a.affiliate_id = c.affiliate_id)
where a.affiliate_id = ?
How about a join:
select * from impressions, clicks, commissions
where impressions.affiliate_id = clicks.affiliate_id
and clicks.affiliate_id = commissions.affiliate_id
and impressions.affiliate_id = '$iAid'