Posts

Clear email queue in SQL Server

Introduction: Hello Guys, “ Welcome back” Today, i am here with another one new great article. In this article I explained how to clear email queue in SQL Server . This article will following SQL Server versions i.e. 2008, 2008R2, 2012, 2014, 2016, 2017, 2019 and 2022. Queued Email in SQL Server Implementation: For detailed understanding regarding Queue email in SQL Server , You can check my last article . The emails send by you but that is still in queued, are seen in msdb.dbo.sysmail_unsentitems table. SELECT * FROM msdb.dbo. sysmail_unsentitems Deleting unsent emails in Queue The emails send by you but that is still in queued, to delete these unsent emails from queue, you need to execute the following DELETE SQL query. DELETE FROM msdb.dbo. sysmail_unsentitems Conclusion:  In above code, I have been explained that how to clear email queue in SQL Server . This code is very helpful for every developer. Bye and take care of you Developers. We will come back ...

Check Email Queue in SQL Server

Introduction: Hello Guys, “ Welcome back” Today, i am here with another one new great article. In this article I explained how to check email queue in SQL Server . Check Email Queue in the Log Tables Implementation: In SQL Server , the information or status of the email that are sending is in the queue in the msdb.dbo.sysmail_unsentitems table until not sent. The below SQL query will be use to check the the email that are in Queue in SQL Server . SELECT   *   FROM   msdb . dbo . sysmail_unsentitems If you are unable to find the email in the above table, then there will be two cases to find the status of the sending email. The name of the two cases is as follows: 1.     Email has been sent 2.     Email has failed Case 1: Email has been sent The emails that are already sent to the mentioned email address without any are stored in the msdb.dbo.sysmail_sentitems table. The below SQL query will be use to check the email that...

Generate comma separated list from Table rows in SQL Server

Introduction: Hello Guys, “ Welcome back” Today, i am here with another one new great article. In this article I explained the implementation about how to generate comma separated list from Table rows in SQL Server . Implementation: I created a table with the named userdetails with the schema as follow. I inserted some records in the table. Here I am also giving SQL Server Database Script, you can execute this  SQL Server Database Script by using copy and paste to create table with column and data.          SET ANSI_NULLS ON GO   SET QUOTED_IDENTIFIER ON GO   SET ANSI_PADDING ON GO   CREATE TABLE [dbo].[userdetails](             [user_id] [int] IDENTITY(1,1) NOT NULL,             [user_name] [varchar](100) NOT NULL,           ...

Instead of Insert Trigger in SQL Server

Introduction: Hello Guys, “ Welcome back” Today, i am here with another one new great article. In this article I explained the implementation about how to create an Instead of Insert Trigger in SQL Server . This article is applicable for all versions of SQLServer i.e. 2005, 2008, 2012, 2014, 2019, 2022 etc. Database Details I created the following table named userdetail with the all details as follows.   Column name           data Type   userid                      int   username                varchar(100)   useremail                varchar(50) useraddress             varchar(250) I have already inserted few records ...