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

  • SEARCH
  • Home
  • 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 7027235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:13:16+00:00 2026-05-28T00:13:16+00:00

I started with the following trigger in SqlServer 2000 ALTER TRIGGER DeleteTrigger ON [dbo].[WarrantyClaimsLineItems]

  • 0

I started with the following trigger in SqlServer 2000

 ALTER TRIGGER DeleteTrigger
 ON [dbo].[WarrantyClaimsLineItems]
 FOR DELETE
 AS 
 begin

    declare @wa int
    SET @wa = (SELECT warrantyAuthNo from DELETED)
    update dbo.warrantyclaimsauth
    set isused = 0
    WHERE warrantyClaimsAuth.warrantyauthno = @wa


end

Basically, whenever a line item is deleted from the table I need to update the warrantyauth.isUsed that was assigned to that line item back to false.

it works when deleting one line item but when multiple line items are deleted I get the following error.

Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

I understand why, the trigger is expecting only one record to be deleted.
so I need to modify it to handle multiple row deletes.

I did some research and modified my trigger to be this

....
 AFTER DELETE
 AS 
 begin

    update dbo.warrantyclaimsauth set isUsed = 0
    from dbo.warrantyclaimsauth a
    inner join deleted d on a.warrantyAuthNo = a.warrantyAuthNo


 end

this however is updating every row in the warrantyclaimsauth with 0 in the isUsed field.
Can anyone help me with what I am doing wrong?
Thank you!

  • 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-28T00:13:17+00:00Added an answer on May 28, 2026 at 12:13 am

    Your join condition is wrong in the second one. Try this:

     AFTER DELETE
     AS 
     begin
    
        update a set isUsed = 0
        from dbo.warrantyclaimsauth a
        inner join deleted d on a.warrantyAuthNo = d.warrantyAuthNo
    
    
     end
    

    You were joining deleted where the warrantyauthno equalled itself, rather than the value from the deleted table. You were essentially just doing a cross join of deleted and not filtering any rows what so ever.

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

Sidebar

Related Questions

I've got the following trigger; CREATE TRIGGER trFLightAndDestination ON checkin_flight AFTER INSERT,UPDATE AS BEGIN
I have only just started received the following error in my windows forms application
I have the following text: started: Project: ProjectA, Configuration: Release Any CPU ------ I
Recently I've switched to Ninject 2.0 release and started getting the following error: Error
I am following the Getting Started guide for wxPython. But unfortunately the first 'Hello
I'm following the Boost Getting Started article. I've installed it with Bjam and I
Following Alan Green's Naming Java classes without Manager I've started hunting *Manager classes in
The following output appears after running some rake tasks: Loaded suite /usr/bin/rake Started Finished
I have just started using jQuery and although following code gets the job done,
I've just started playing with Django and am loosely following the tutorial with my

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.