Questions about the inability to bind identifiers composed of multiple parts in MS sqlserver

Source: Internet
Author: User

A trigger is written to update the status of the corresponding records in the subtable of the record after a record is deleted.

First, it is written as follows:

Create trigger update_sended on oa_goodssending
After Delete
Update oa_commit_inform_list set sendid = '0' where sendid = deleted. sendid

I thought this would work. Because the deleted data is stored in the deleted table during the delete operation, use the deleted table directly. Who knows the following error:

Message 4104, level 16, status 1, process update_sended, 3rd rows
Unable to bind the identifier "deleted. sendid" consisting of multiple parts ".

 

After careful research, I found that the data in the deleted table must be selected first, so I changed it

Create trigger update_sended on oa_goodssending
After Delete
Declare @ sendid varchar (50) -- Issuance ID
Select @ sendid = sendid from deleted
-- Print @ sendid
Update oa_commit_inform_list set sendid = '0' where
Sendid = @ sendid

Everything is done!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.