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 8728909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:44:10+00:00 2026-06-13T08:44:10+00:00

I have created a trigger in SQL Server 2008 CREATE TRIGGER [dbo].[ITEM_UOM_DELETE] ON [dbo].[ITEM_UOM]

  • 0

I have created a trigger in SQL Server 2008

CREATE TRIGGER [dbo].[ITEM_UOM_DELETE] ON
   [dbo].[ITEM_UOM] INSTEAD OF DELETE
   AS
      declare @rowc int
      set @rowc = (select count(*) from stock, deleted where 
      item = deleted.itemcode and uom = DELETED.MAINUNIT AND DOCTYPE <> 'OP')
         if @rowc > 0
         begin
           raiserror('Unit is in Use Cannot Delete', 16, 1)
           rollback transaction
         end

on execution of this trigger it gives the error output

Msg 50000, Level 16, State 1, Procedure ITEM_UOM_DELETE, Line 11
Unit is in Use Cannot Delete
Msg 3609, Level 16, State 1, Line 1
The transaction ended in the trigger. The batch has been aborted.

I want the defined error only

Unit is in Use Cannot Delete

How to remove the error ‘The transaction ended in the trigger. The batch has been aborted.’ ?

  • 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-06-13T08:44:11+00:00Added an answer on June 13, 2026 at 8:44 am
    CREATE TRIGGER [dbo].[ITEM_UOM_DELETE] ON
    [dbo].[ITEM_UOM] INSTEAD OF DELETE
    AS
    BEGIN
    
    declare @rowc int
    select @rowc=count(*) from stock
    
    if @rowc <= 0
    begin
    deleted uom from [ITEM_UOM] uom inner join deleted on uom.item = deleted.itemcode 
    and uom.MAINUNIT = DELETED.MAINUNIT where uom.DOCTYPE <> 'OP'
    end
    else
    begin
    raiserror('Unit is in Use Cannot Delete', 16, 1)
    end
    
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I work with SQL Server 2008 R2 I have a simple trigger CREATE TRIGGER
I have a SQL Server 2008 database that has a Trigger. This trigger is
I got the following trigger on my sql server 2008 database CREATE TRIGGER tr_check_stoelen
I need to create trigger in SQL Server 2008 that gone insert all values
In SQL Server 2008, is it possible to create a column that can have
I'm trying to create a simple trigger using TSQL (or SQL Server 2008). The
I am trying to create a trigger in SQL Server 2008 which inserts a
I have a view that has an INSTEAD OF INSERT trigger (in SQL Server
SQL Server 2005+ I have a view with an INSTEAD OF INSERT trigger. Inside
I have a small problem with an update trigger under SQL Server 2008 R2.

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.