Using SSRS 2012, we utilize report subscriptions to save reports network locations and send reports by email. I am familiar with how to debug errors, but I am looking for a solution to alert our support team when a subscription has failed to send. Call me crazy for being proactive.
I see a solution to monitor the ReportServer tables for status, but it assumes all subscriptions are by email (only handles email statuses).
I also see the execution log table(ExecutionLog3), but the table doesn't appear to capture all errors. I forced a subscription to fail by removing network access to the file location, but the error doesn't appear in the table.
I would like to write an SSRS report which can be run to view all subscription errors that have occurred for a day. Any suggestions are appreciated.
This does only handle the last status message so doesn't fully answer the question (I came across this post because I am looking for the same answer), but it does seem to work for me in terms of catching all subscription errors, including file share issues:
select count(*)
from ReportServer.dbo.[Subscriptions] S
where 0 = case
when S.[LastStatus] = 'New Subscription' then 1
when substring(S.[LastStatus],1,9) = 'Mail Sent' then 1
when substring(S.[LastStatus],1,5) = 'Done:'
and right(S.[LastStatus],9) = '0 errors.' then 1
when substring(S.[LastStatus],1,9) = 'The file '
and patindex('%has been saved to the%',S.[LastStatus]) > 1
and right(S.[LastStatus],11) = 'file share.' then 1
else 0
end
I have used Report Server Diagnostic Reports pack from Microsoft
More info about the Report Server Diagnostic Reports (snapshots)
Download link for Report Server Diagnostic Reports Pack
I have not used this but i have heard about it
Free SQL Monitor SSRS Reporting Pack
There is no built in way to do this. You will have to parse the Windows error log or the reporting services log. I have not tried this but the ssrs api might return the last subscription status for subscription based reports, however there is not historical log outside of the ReportingService database and even there I am not sure if failures are logged.
Check out this solution I found on Jeff Prom's blog, http://jeffprom.com/2008/08/22/ssrs-failed-subscription-notifications/
SELECT C.Name, S.LastRunTime, S.LastStatus, S.Description
FROM Subscriptions AS S
LEFT OUTER JOIN [Catalog] AS C
ON C.ItemID = S.Report_OID
WHERE LEFT (S.LastStatus, 12) != ‘Mail sent to’
AND LEFT (S.LastStatus, 12) != ‘New Subscrip’
Related
I use Access at work, I'm mostly self-taught and I know very little code . I've built a data base for handling HR KPI´S. In some of my queries, since 2016 started (2015 still runs), several reports I run now pops the error:
"The Microsoft Access Database Engine does not recognize 'C_Hrs_Permiso_TI_NT.NOTRAB' as a valid field name or expression".
I'm not sure why the report would be giving me an error about it.
Query Code:
TRANSFORM Sum(Hrs_Permiso_TI_NT.MONTOO) AS SumaDeMONTOO
SELECT Hrs_Permiso_TI_NT.EMPRESA,
Hrs_Permiso_TI_NT.CENCOS,
Left([Hrs_Permiso_TI_NT]![AMES],4) AS Año,
Right([Hrs_Permiso_TI_NT]![AMES],2) AS Mes,
Hrs_Permiso_TI_NT.CODIGO,
Fecha_maxmes_Calendario.MáxDeFecha
FROM Hrs_Permiso_TI_NT INNER JOIN Fecha_maxmes_Calendario
ON Hrs_Permiso_TI_NT.AMES=Fecha_maxmes_Calendario.Ames
GROUP BY Hrs_Permiso_TI_NT.EMPRESA,
Hrs_Permiso_TI_NT.CENCOS,
Left([Hrs_Permiso_TI_NT]![AMES],4),
Right([Hrs_Permiso_TI_NT]![AMES],2),
Hrs_Permiso_TI_NT.CODIGO,
Fecha_maxmes_Calendario.MáxDeFecha
PIVOT Hrs_Permiso_TI_NT.COHADE;
As soon as this query doesn't contain C_Hrs_Permiso_TI_NT, it means that the problem is one of queries 'Hrs_Permiso_TI_NT' or Fecha_maxmes_Calendario. Try to open them and locate error
By developing client server applications in Delphi + SQL Server I continuously face the problem to have an exact report of what an action caused on db.
A simple example is:
BEFORE: start "capturing" the DB
user changes a value in an editbox
the user presses a "save" button
AFTER: stop "capturing" the DB
I would like to have a tool that compares the before and after status (I manually capture the BEFORE and AFTER status).
I googled for this kind of tools but all I found are tools for doing data or schema comparison between more datasources.
Thanks.
The following is an extract for an application we have. This code is in a BeforePost event handler that is linked to all of the Dataset components in the application. This linking is done using code as there are a lot of datasets. This doesn't actually log the changes (just lists the fields) but it should be simple enough to change to meet your objective. I don't know if this is exactly right for what you are trying to achieve since you ask for a tool but it would be an effective way of creating a report of all changes
CurrentReport := Format('Table %s modified', [DataSet.Name]);
for i := 0 to DataSet.FieldCount - 1 do
begin
XField := DataSet.Fields[i];
if (XField.FieldKind = fkData) and (XField.Value <> XField.OldValue) then
begin
CurrentReport := CurrentReport + Format(', %s changed', [XField.FieldName])
end;
end;
Note that our code collects a report but only logs it after the post has been successfully completed
In order to send automated job failure notifications from SQL Server Agent, you must configure Database Mail and then to to SQL Agent properties > Alert System > Mail Session > Enable mail profile to configure the mail system and mail profile to be used to send the email notifications. We have many servers, and would like to setup a central cross-server job that ensures that the Enable mail profile option is checked across various servers, because otherwise, the scheduled jobs fail silently without sending an email notification.
Is there a supported way to query the msdb database to get to these settings using T-SQL (or by some other way programmatically)?
Running a SQL Profiler trace while bringing up the properties page in the SQL Server Agent UI shows references to msdb.dbo.sp_get_sqlagent_properties which is an undocumented procedure (I would prefer to use documented objects to help future-proof our solution), and several calls to master.dbo.xp_instance_regread which I would imagine the reg keys could change per each SQL Server instance installation.
Does anyone know of a way to query to check whether the enable mail profile option is configured, and also retrieve the mail profile that is designated in the SQL Agent Alert System configs? Most of our servers are SQL Server 2008 R2, with some SQL 2012. I would prefer SQL 2008+ support.
Thanks in advance!
Future-proofing is a very wise idea :). As you noted, both xp_regread and xp_instance_regread are also undocumented. And http://social.msdn.microsoft.com/Forums/sqlserver/en-US/b83dd2c1-afde-4342-835f-c1debd73d9ba/xpregread explains your concern (plus, it offers you an alternative).
Your trace and your run of sp_helptext 'sp_get_sqlagent_properties' are a good start. The next thing to do is run sp_helptext 'sp_helptext', and note its reference to sys.syscomments. BOL sys.syscomments topic redirects you to sys.sql_modules, and that points to the next step. Unfortunately for your needs, just one row (for 'sp_get_sqlagent_properties') will be returned by running USE msdb; SELECT object_name(object_id) FROM sys.sql_modules WHERE definition LIKE '%sp_get_sqlagent_properties%'. I thus assume you are out of luck - there appears to be no alternative, publicly documented, module (sproc). My assumption could be wrong :).
I deduce that xp_reg% calls exist for client (SMO, SSMS, etc.) needs, such as setting/getting agent properties. More importantly (for your needs), your sp_helptext run also reveals SSMS (a client) is using a registry store (i.e. not a SQL store). Unfortunately, I must deduce (based upon an absence of proof from a library search) that those keys (and their values) are also not documented...
The above appears to put you in a pickle. You could decide "if we are going to rely upon undocumented registry keys, we might as well rely on the undocumented calls to read them", but I won't recommend that:). You could also file a feature request at https://connect.microsoft.com/ (your need is clear), but because your need concerns a client-side feature request, I do not recommend holding your breath while waiting for a fix :).
Perhaps it is time to step back and take a look at the bigger picture:
How often can that key be changed, and how often will this process poll for that change?
Email uses a mail primitive. Sender: "Dear recipient, did you get my mail?" Recipient: "Dear sender, did you send me mail?" Disabling an email profile is not the only reason for an email failure.
Would a different approach be more useful, when compared to periodically checking a key?
One approach would be to periodically send "KeepAlive" email. If the "KeepAlive" email isn't periodically received, maybe that key was tweaked, maybe the Post Office is on a holiday, or maybe something else (equally bad) happened. Plus, this approach should be fully supported, documented, and be future-proof. Who knows how and what keys will be used in the next version of SQL Server Agent?
The first bullet isn't addressed (neither would it be addressed by periodically checking a key), and perhaps you have additional needs (worth mentioning on MS connect).
I finally found a way to do this using PowerShell and Microsoft.SqlServer.Management.Smo.Agent.JobServer.
Here is the PowerShell script I wrote to check if SQL Agent mail alerts are enabled, and to make sure that SQL Agent is set to Auto startup when the server reboots. This works works with local or remote SQL instances.
# usage examples
Check-SQLAgentConfiguration -InstanceName 'localhost\sql2014'
Check-SQLAgentConfiguration -InstanceName 'RemoteServerName'
function Check-SQLAgentConfiguration{
param([string]$InstanceName='localhost')
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null;
$smosrv = new-object Microsoft.SqlServer.Management.Smo.Server($InstanceName);
$smosrv.ConnectionContext.ConnectTimeout = 5; #5 seconds timeout.
$smosrv.ConnectionContext.ApplicationName = 'PowerShell Check-SQLAgentConfiguration';
"Server: {0}, Instance: {1}, Version: {2}, Product Level: {3}" -f $smosrv.Name, $smosrv.InstanceName, $smosrv.Version, $smosrv.ProductLevel;
# NOTE: this does not seem to ever fail even if SQL Server is offline.
if(!$smosrv){"SQL Server Connection failed"; return $null;}
$agent = $smosrv.JobServer;
if(!$agent -or $agent -eq $null){
throw "Agent Connection failed";
return -2;
}
$agentConfigErrMsg = "";
if($agent.AgentMailType -ne "DatabaseMail"){ $agentConfigErrMsg += " AgentMailType: " + $agent.AgentMailType + "; "; }
if(!$agent.DatabaseMailProfile){$agentConfigErrMsg += " DatabaseMailProfile: " + $agent.DatabaseMailProfile + "; ";}
if($agent.SqlAgentAutoStart -ne "True"){$agentConfigErrMsg += " SqlAgentAutoStart: " + $agent.SqlAgentAutoStart + " ServiceStartMode: " + $agent.ServiceStartMode + "; "; }
if($agentConfigErrMsg.length -gt 0){
$agentConfigErrMsg = "Invalid SQL Agent config! " + $agentConfigErrMsg;
throw $agentConfigErrMsg;
return -1;
}
<##
#for debugging:
"Valid: "
"AgentMailType:" + $agent.AgentMailType;
"DatabaseMailProfile: " + $agent.DatabaseMailProfile;
"ServiceStartMode: " + $agent.ServiceStartMode;
"SqlAgentAutoStart: " + $agent.SqlAgentAutoStart;
#"SqlAgentMailProfile: " + $agent.SqlAgentMailProfile;
#>
return 0;
}
SQL 2008R2 uses Service-broker like queues for mail processing (http://technet.microsoft.com/en-us/library/ms175887%28v=sql.105%29.aspx). In our environments I check that the corresponding queue exists and is active.
SELECT * FROM msdb.sys.service_queues
WHERE name = N'ExternalMailQueue'
AND is_receive_enabled = 1;
This table is listed online (http://technet.microsoft.com/en-us/library/ms187795%28v=sql.105%29.aspx).
Testing shows that this makes the required transition as we went from new instance -> enabled mail -> mail switched off and back again.
We use the DBAmp for integrating Salesforce.com with SQL Server (which basically adds a linked server), and are running queries against our SF data using OPENQUERY.
I'm trying to do some reporting against opportunities and want to return the created date of the opportunity in the opportunity owners local date time (i.e. the date time the user will see in salesforce).
Our dbamp configuration forces the dates to be UTC.
I stumbled across a date function (in the Salesforce documentation) that I thought might be some help, but I get an error when I try an use it so can't prove it, below is the example useage for the convertTimezone function:
SELECT HOUR_IN_DAY(convertTimezone(CreatedDate)), SUM(Amount)
FROM Opportunity
GROUP BY HOUR_IN_DAY(convertTimezone(CreatedDate))
Below is the error returned:
OLE DB provider "DBAmp.DBAmp" for linked server "SALESFORCE" returned message "Error 13005 : Error translating SQL statement: line 1:37: expecting "from", found '('".
Msg 7350, Level 16, State 2, Line 1
Cannot get the column information from OLE DB provider "DBAmp.DBAmp" for linked server "SALESFORCE".
Can you not use SOQL functions in OPENQUERY as below?
SELECT
*
FROM
OPENQUERY(SALESFORCE,'
SELECT HOUR_IN_DAY(convertTimezone(CreatedDate)), SUM(Amount)
FROM Opportunity
GROUP BY HOUR_IN_DAY(convertTimezone(CreatedDate))')
UPDATE:
I've just had some correspondence with Bill Emerson (I believe he is the creator of the DBAmp Integration Tool):
You should be able to use SOQL functions so I am not sure why you are
getting the parsing failure. I'll setup a test case and report back.
I'll update the post again when I hear back. Thanks
A new version of DBAmp (2.14.4) has just been released that fixes the issue with using ConvertTimezone in openquery.
Version 2.14.4
Code modified for better memory utilization
Added support for API 24.0 (SPRING 12)
Fixed issue with embedded question marks in string literals
Fixed issue with using ConvertTimezone in openquery
Fixed issue with "Invalid Numeric" when using aggregate functions in openquery
I'm fairly sure that because DBAmp uses SQL and not SOQL, SOQL functions would not be available, sorry.
You would need to expose this data some other way. Perhaps it's possible with a Salesforce report, web-service, or compiling the data through the program you are using to access the (DBAmp) SQL Server.
If you were to create a Salesforce web service, the following example might be helpful.
global class MyWebService
{
webservice static AggregateResult MyWebServiceMethod()
{
AggregateResult ar = [
SELECT
HOUR_IN_DAY(convertTimezone(CreatedDate)) Hour,
SUM(Amount) Amount
FROM Opportunity
GROUP BY HOUR_IN_DAY(convertTimezone(CreatedDate))];
system.debug(ar);
return ar;
}
}
I was wondering if someone knows where I can see the data of a suspended message in the biztalk database.
I need this because about 900 messages have been suspended because of a validation and I need to edit all of them, resuming isn't possible.
I know that info of suspended messages are shown in BizTalkMsgBoxDb in the table InstancesSuspended and that the different parts of each message are shown in the table MessageParts. However I can't find the table where the actual data is stored.
Does anyone have any idea where this can be done?
I found a way to do this, there's no screwing up my system when I just want to read them.
How I did it is using the method "CompressionStreams" using Microsoft.Biztalk.Pipeline.dll.
The method to do this:
public static Stream getMsgStrm(Stream stream)
{
Assembly pipelineAssembly = Assembly.LoadFrom(string.Concat(#"<path to dll>", #"\Microsoft.BizTalk.Pipeline.dll"));
Type compressionStreamsType = pipelineAssembly.GetType("Microsoft.BizTalk.Message.Interop.CompressionStreams", true);
return (Stream)compressionStreamsType.InvokeMember("Decompress", BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Static, null, null, new object[] { (object)stream });
}
Then I connect with my database, fill in a dataset and stream out the data to string, code:
String SelectCmdString = "select * from dbo.Parts";
SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(SelectCmdString, "<your connectionstring">);
DataSet myDataSet = new DataSet();
mySqlDataAdapter.Fill(myDataSet, "BodyParts");
foreach (DataRow row in myDataSet.Tables["BodyParts"].Rows)
{
if (row["imgPart"].GetType() != typeof(DBNull))
{
SqlBinary binData = new SqlBinary((byte[])row["imgPart"]);
MemoryStream stm = new MemoryStream(binData.Value);
Stream aStream = getMsgStrm(stm);
StreamReader aReader = new StreamReader(aStream);
string aMessage = aReader.ReadToEnd();
//filter msg
//write msg
}
}
I then write each string to an appropriate "txt" or "xml" depending on what u want, you can also filter out certain messages with regular expression, etc.
Hope this helps anyone, it sure as hell helped me.
Greetings
Extract Messages from suspended instances
Scenario:
BizTalk 2010 and SQL 2008 R2 is the environment we have used fore this scenario.
You have problem with some integrations, 1500 suspended instances inside BizTalk and you need to send the actual messages to a customer, and then you properly do not want to manually save out this from BizTalk Administrator.
There are a lot of blogs and Internet resources pointing out vbs, powershell scripts how to do this, but I have used BizTalk Terminator to solve this kind of scenarios.
As you now BizTalk terminator is asking you 3 questions when the tool starts
I.1.All BizTalk databases are backed up?
II.2.All Host Instances is stopped?
III.3.All BizTalk SQL Agents is stopped?
This is ok when you are going to actually change something inside BizTalk databases but this is not what you are going to do in this scenario you are only using the tool to read from BizTalk databases. But you should always have backups off BizTalk databases.
You are always responsible for what you are doing, but when we have used this tools in the way I describe we have not have any problem with this scenario.
So after you have start Terminator tool please click yes to the 3 questions(you dont need to stop anything in this scenario) then connect to the correct environment please do this in your test environment first so you feel comfortable with this scenario, the next step is to choose a terminator task choose Count Instances(and save messages) after this you have to fill in the parameter TAB with correct serviceClass and Hostname and set SaveMessages to True and last set FilesaveFullPath to the correct folder you want to save the messages to.
Then you can choose to click on the Execute Button and depending of the size and how many it can take some time, after this disconnect Terminator do NOT do anything else.
You should now if you have filled in the correct values in the parameter TAB have the saved messages inside the FilesaveFullPath folder.
Download BizTalk terminator from this address:
http://www.microsoft.com/en-us/download/details.aspx?id=2846
This is more than likely not supported by Microsoft. Don't risk screwing up your system. If you have a need to have a edit and resubmit, it needs to be built into the orchestration. Otherwise, your best bet is to use WMI to write a script to:
pull out all of the suspended messages
terminate them
edit them
resubmit them
you can find it through the HAT tool you just need to specify the schema ,port and the exact date
with the exact time and it will show you the messages right click on the desired one and save .