0% found this document useful (0 votes)
5 views1 page

User Level ActivityNotificationScript

The document outlines a SQL query that populates a temporary table with user notifications for companies where notifications are enabled. It checks for the existence of specific notifications before inserting new records into the 'user_app_notification' table. The final insertion includes details such as company notification ID, company ID, user ID, and timestamps for newly created records.

Uploaded by

mak.ronaldo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

User Level ActivityNotificationScript

The document outlines a SQL query that populates a temporary table with user notifications for companies where notifications are enabled. It checks for the existence of specific notifications before inserting new records into the 'user_app_notification' table. The final insertion includes details such as company notification ID, company ID, user ID, and timestamps for newly created records.

Uploaded by

mak.ronaldo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

--Fill Record in Temp With Clause

;WITH tempusernotification (User_Id,Company_Id)AS


(
Select Tbl.User_Id,Tbl.Company_Id
From(
SELECT
distinct UAN.User_Id,UAN.Company_Id
FROM user_app_notification UAN
where Uan.isEnable=1
)Tbl
WHERE NOT EXISTS (SELECT User_Id FROM user_app_notification UAN
INNER JOIN company_app_notification CAN ON CAN.companyNotifyId =
UAN.companyNotifyId
And UAN.Company_Id = CAN.Company_Id
WHERE UAN.User_Id = Tbl.User_Id AND appnotifyid=12 )
)-- Insert Record From With Clause
INSERT [dbo].[user_app_notification] ([companyNotifyId], [Company_Id], [User_Id],
[isEnable], [created_dttm])
select CAN.companyNotifyId,UAN.Company_Id,UAN.User_Id,1 as isEnable,getdate()as
created_dttm
from tempusernotification UAN
INNER JOIN company_app_notification CAN ON CAN.Company_Id = UAN.Company_Id
WHERE appnotifyid=12
order by UAN.Company_Id,UAN.User_Id

You might also like