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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:08:40+00:00 2026-06-13T20:08:40+00:00

On a table in MS SQL Server I need to run a CLR Stored

  • 0

On a table in MS SQL Server I need to run a CLR Stored Procedure on new rows if those rows meet certain criteria. I thought that would be more or less straightforward:

if ((SELECT Cabinet FROM INSERTED) = 1 OR (SELECT Cabinet FROM INSERTED) = 3) AND (SELECT Result_02 FROM INSERTED) = 'N'
BEGIN
    DECLARE @id int
    SET @id = (SELECT ID FROM INSERTED)
    exec PrintLabel
        @id,
        N'LP 2844 LGE'
END;

However, this recently started throwing errors about a subquery returning multiple rows. I learned that INSERT triggers run once for each statement, not necessarily on individual rows. So, that IF statement can be working on multiple rows, and thus the error.

My question is: how can I iterate over each new row if the rows are added in a batch (in this case via a MERGE statement).

  • 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-13T20:08:41+00:00Added an answer on June 13, 2026 at 8:08 pm

    Calling a stored procedure for N rows still requires a cursor.

    declare @id int
    declare cur cursor fast_forward for 
        select  id 
        from    inserted 
        where   Cabinet in (1,3)
    open cur
    fetch next from cur into @id
    while @@fetch_status = 0   
        begin
        exec PrintLabel @id, N'LP 2844 LGE'
        fetch next from cur into @id
        end
    close cur
    deallocate cur
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I debug a stored procedure (SQL Server 2005) and I need to find out
I need to run the replication of one table in SQL Server 2005. Replication
Possible Duplicate: Saving changes after table edit in SQL Server Management Studio I need
I need to check If a column value (string) in SQL server table starts
In SQL Server, I need to design a User table. It should have a
I need to filter out junk data in SQL (SQL Server 2008) table. I
I have a table with ~1M rows and run the following SQL against it:
I have a SQL Server table. I need to create the same table in
The following queries run in an sproc targeting the ItemData table in SQL Server
Nightly, I need to fill a SQL Server 2005 table from an ODBC source

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.