Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6383831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:41:57+00:00 2026-05-25T02:41:57+00:00

If a user inserts rows into a table, i would like SQL Server to

  • 0

If a user inserts rows into a table, i would like SQL Server to perform some additional processing – but not in the context of the user’s transaction.

e.g. The user gives read access to a folder:

UPDATE Folders SET ReadAccess = 1
WHERE FolderID = 7

As far as the user is concerned i want that to be the end of the atomic operation. In reality i have to now go find all child files and folders and give them ReadAccess.

EXECUTE SynchronizePermissions

This is a potentially lengthy operation (over 2s). i want this lengthy operation to happen “later“. It can happen 0 seconds later, and before the carbon-unit has a chance to think about it the asynchronous update is done.

How can i run this required operation asychronously when it’s required (i.e. triggered)?

The ideal would be:

CREATE TRIGGER dbo.Folders FOR INSERT, UPDATE, DELETE AS
   EXECUTEASYNCHRONOUS SynchronizePermissions

or

CREATE TRIGGER dbo.Folders FOR INSERT, UPDATE, DELETE AS
   EXECUTE SynchronizePermissions WITH(ASYNCHRONOUS)

Right now this happens as a trigger:

CREATE TRIGGER dbo.Folders FOR INSERT, UPDATE, DELETE AS
   EXECUTE SynchronizePermissions

and the user is forced to wait the 3 seconds every time they make a change to the Folders table.

i’ve thought about creating a Scheduled Task on the user, that runs every minute, and check for an PermissionsNeedSynchronizing flag:

CREATE TRIGGER dbo.Folders FOR INSERT, UPDATE, DELETE AS
   UPDATE SystemState SET PermissionsNeedsSynchronizing = 1

The scheduled task binary can check for this flag, run if the flag is on:

DECLARE @FlagValue int
SET @FlagValue = 0;

UPDATE SystemState SET @FlagValue = PermissionsNeedsSynchronizing+1
WHERE PermissionsNeedsSynchronizing = 1

IF @FlagValue = 2
BEGIN
   EXECUTE SynchronizePermissions

   UPDATE SystemState SET PermissionsNeedsSynchronizing = 0
   WHERE PermissionsNeedsSynchronizing = 2
END

The problem with a scheduled task is:
– the fastest it can run is every 60 seconds
– it’s suffers from being a polling solution
– it requires an executable

What i’d prefer is a way that SQL Server could trigger the scheduled task:

CREATE TRIGGER dbo.Folders FOR INSERT, UPDATE, DELETE AS
   EXECUTE SynchronizePermissionsAsychronous


CREATE PROCEDURE dbo.SynchronizePermissionsAsychronous AS

   EXECUTE sp_ms_StartWindowsScheduledTask @taskName="SynchronousPermissions"

The problem with this is:
– there is no sp_ms_StartWinodowsScheduledTask system stored procedure

So i’m looking for ideas for better solutions.


Update: The previous example is a problem, that has has no good solution, for five years now. A problem from 3 years ago, that has no good solution is a table that i need to update a meta-data column after an insert/update. The metadata takes too long to calculate in online transaction processing, but i am ok with it appearing 3 or 5 seconds later:

CREATE TRIGGER dbo.UpdateFundsTransferValues FOR INSERT, UPDATE AS

UPDATE FundsTransfers
SET TotalOrderValue = (SELECT ....[snip]....),
    TotalDropValue = (SELECT ....,[snip]....)
WHERE FundsTransfers.FundsTransferID IN (
    SELECT i.FundsTransferID
    FROM INSERTED i
)

And the problem that i’m having today is a way to asychronously update some metadata after a row has been transitionally inserted or modified:

CREATE TRIGGER dbo.UpdateCDRValue FOR INSERT, UPDATE AS

UPDATE LCDs
SET CDRValue = (SELECT ....[snip]....)
WHERE LCDs.LCDGUID IN (
    SELECT i.LCDGUID
    FROM INSERTED i
)

Update 2: i’ve thought about creating a native, or managed, dll and using it as an extended stored procedure. The problem with that is:

  • you can’t script a binary
  • i’m now allowed to do it
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:41:58+00:00Added an answer on May 25, 2026 at 2:41 am

    Use a queue table, and have a different background process pick things up off the queue and process them. The trigger itself is by definition a part of the user’s transaction – this is precisely why they are often discouraged (or at least people are warned to not use expensive techniques inside triggers).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a simple program to insert rows into a table.But when i
If user input is inserted without modification into an SQL query, then the application
I want to update a list of storage devices as the user inserts USB
Im using smarty and mysql_real_escape_string() for user input, and when I insert some code
User A logs into a ticket management system to edit content on SomePage.aspx User
I am copying some user data from one SqlServer to another. Call them Alpha
I would like to apologize if the duplicate of this question exist. i tried
I have a website that has user ranking as a central part, but the
I have two tables users registered_members I want to confirm values from user table
How do I select all rows for a table, their isn't part of any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.