I am sending emails from SQL Server, and need to map the values of the sent_status column on the msdb.dbo.sysmail_mailitems table to something more descriptive.
So far I have identified two values:
1 = 'Sent'
2 = 'Failed'
Are there any more possible values, and if so what do they represent?
sent_status, --0 new, not sent, 1 sent, 2 failure or 3 retry.
On the MSDN page for the related msdb.dbo.sysmail_allitems table, the description for sent_status says:
The status of the mail. Possible values are:
sent - The mail was sent.
unsent - Database mail is still attempting to send the message.
retrying - Database Mail failed to send the message but is
attempting to send it again.
failed - Database mail was unable to send the message.
Connecting the two views together as follows:
SELECT DISTINCT mi.sent_status, ai.sent_status
FROM
msdb.dbo.sysmail_allitems ai
FULL OUTER JOIN
msdb.dbo.sysmail_mailitems mi ON
ai.mailitem_id = mi.mailitem_id
Will yield a relationship, which can be expressed with the following CASE statement:
SELECT
CASE sent_status
WHEN 0 THEN 'Unsent'
WHEN 1 THEN 'Sent'
WHEN 2 THEN 'Failed'
WHEN 3 THEN 'Retrying'
END AS sent_status_desc
FROM msdb..sysmail_mailitems
Related
for example sql-client.sh embedded
insert into wap_fileused_daily(orgId, pdate, platform, platform_count) select u.orgId, u.pdate, coalesce(p.platform,'other'), sum(u.isMessage) as platform_count from users as u left join ua_map_platform as p on u.uaType = p.uatype where u.isMessage = 1 group by u.orgId, u.pdate, p.platform
it will show up as:enter image description here
there will never be any checkpoint.
Question: 1) how to trigger checkpoint ( alert job)
2) how to recover in case of failure
You can specify execution configuration parameters in the SQL Client YAML file. For example, the following should work:
configuration:
execution.checkpointing.interval: 42
There is a feature request on flink:https://cwiki.apache.org/confluence/display/FLINK/FLIP-147%3A+Support+Checkpoints+After+Tasks+Finished
I am trying to implement a server-client communication. I am executing a sql statement (SQLITE3)
"UPDATE users SET status=1 WHERE username='%s' AND password='%s';",user,pass);
using qlite3_prepare_v2
I know how to write to client, but I don't know how to CHECK if the 'status' has been set to 1 where username is user and password is pass AND how to send a reply to client: "Yes, the 'status' has been set to 1, you are now logged in"
int sqlite3_changes(sqlite3*); returns the number of rows modified, inserted or deleted by the most recently completed INSERT, UPDATE or DELETE statement.
After your query, check if one row was modified.
Source: https://www.sqlite.org/c3ref/changes.html
I am using Service broker in two instances in two physical servers .with this instrument :
http://www.sqlservercentral.com/articles/Service+Broker/2797/
I set all certificate and all other options for both servers .I am using this code to send a message to target machine :
Declare #ConversationHandle uniqueidentifier
Begin Transaction
Begin Dialog #ConversationHandle
From Service SenderService
To Service 'ReceiverService'
On Contract SampleContract
WITH Encryption=off;
SEND
ON CONVERSATION #ConversationHandle
Message Type SenderMessageType
('<test>test</test>')
Commit
But when i check the target queue no messages exist.So i check the sys.transmission_queue in sender machine and i found this :
All messages are here .why ?how can i found the problem ?
I check the sys.conversation_endpoints
6720A2A2-C8F6-E811-80E3-40A8F038BB1F 802A7832-100B-4093-BEF3-B91ACB98EA13 1 65536 6820A2A2-C8F6-E811-80E3-40A8F038BB1F 65536 2086-12-21 10:11:09.720 CO CONVERSING ReceiverService NULL 1 7 A3DAEFBC-2ADA-4C46-8F44-3FC9882BADD1 00000000-0000-0000-0000-000000000000 1900-01-01 00:00:00.000 1900-01-01 00:00:00.000 1 0x02388E050000 -1 0 0 0 -1 0 0 0 5
Finally i used this (enter link description here)post to find the problem .
The problem was the time different between two machines.
I have a table listing patient_clinic_visits. I have SQLSERVER 2005 backend. Access2010 frontend.
Each morning this table needed refreshing from a data dump from the hospital mainframe.
this data dump includes information on the day before (who attended, didn't, cancelled) and forward appointments for next 6 weeks.
I therefore do a "DELETE * from Patient_clinic_visits where Visit_Date > (a day) and < (a day + 1) to clean out the table for each day in turn before uploading the new data after some processing.
On most days there will be only about 100-150 records in each day. Their is one foreign key to Pat_ID in Master_Patient_Table which has NO_ACTION chain on it.
At the moment this Delete query is timing-out in the Access frontend after processing a couple of days of data (ie it works okay for Monday, Tuesday, Wednesday...)
I run sp_whoisactive and get:
00 01:53:01.926 52 [[query SELECT 1 FROM "dbo"."Patient_Clinic_Visits" ]] RAHCC_User (265ms)ASYNC_NETWORK_IO 0 0 0 NULL 51 0 0 2 suspended 0 NULL SAH0020663 RAHCC_DB Microsoft MDB RAHCC 2013-04-02 09:08:33.027 0 2013-04-02 11:01:35.033
00 00:00:27.610 53 [[query --
DELETE from Patient_Clinic_Visits WHERE clinic_date >= '26-Mar-2013' AND clinic_date < '27-Mar-2013' AND Clinic_location = 'MONC' ]] HAD\jhogan05 (27596ms)LCK_M_IX 16 0 0 52 1,074 0 0 130 suspended 2 NULL SAH0048645 RAHCC_DB Microsoft SQL Server Management Studio Express - Query 2013-04-02 11:01:07.343 0 2013-04-02 11:01:35.033
This indicates my client front end is waiting on a "SELECT 1 from Patient_Clinic_Vists" and this is blocking the procedure. Apparently this is due to an ASYNC_NETWORK_IO on the client (which can happen with Access front ends doing a table request and then not processing the data).
a) However a "SELECT 1 from Patient_Clinic_Visits" should really only return TRUE or FALSE ?? which is unlikely to fill up anything, and unclear why it would cause a block situation??
b) I can't find "SELECT 1..." in my Access frontend anywhere.. Is this perhaps part of a sequence of sub-selects made by SQLSERVER in response to a more complext select? If so how do I find the true select causing this situation in that process history?
cheers,
JonHD
a) The query "SELECT 1 from Patient_Clinic_Visits" will return either an empty result set (if the Patient_Clinic_Visits table is empty) or a result set with as many rows as the Patient_Clinic_Visits table, each row having a 1 in it. To do this, SQL Server will have to issue a query against the whole Patient_Clinic_Visits table, which (assuming default locking behavior) will cause shared (read) locks to be issues against the rows in that table.
b) (NOTE: the OP addressed this point in the comments) I might be missing something, but I don't see where you come up with the "SELECT 1 from Patient_Clinic_Vists" query based on sp_whosactive. The best way to understand the SQL being sent from your application to the database server might be to use SQL Profiler with an appropriate filter (perhaps filtering only for connections from the host running your application).
I have a table that contains the order status and email address , If I do a select * statement this is my output
Name. Email Adress Approval code Order states. Qty tickets.
Juan Rivera. Juan #anyemail.com. Null. 1 50
Maria Rosales Maria #anyemail.com. 5567657. 1. 25 Jose Almonte. Jose#anyemail.com. Null. 1. 10
What I would like to do is run a stored procedure everynight and send an email to every user that has a null in the approval code, for example :
Dear : Jose ,
We noticed that your order does not contain an approval code , this order is scheduled to be canceled unless an approval code is entered in the next 72 hours.
Thanks you
Is this possible ?
Please refer SQL SERVER – 2008 – Configure Database Mail – Send Email From SQL Database