We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

SSIS, need to get number of rows deleted from SQL Task

Medium Priority
2,215 Views
Last Modified: 2013-11-10
Hi guys

I have an Execute SQL Task which is a simple DELETE query..   DELETE FROM SomeTable

What is the easiest way to extract the number of rows deleted into an SSIS variable?
We have a custom error handling / dynamic connections / logging tool for SSIS, and it uses variables to store records inserted/written for specific containers/tasks, but I haven't figured out delete yet.

Thanks in advance.
Jim
Comment
Watch Question

CERTIFIED EXPERT
Awarded 2008
Awarded 2008
Commented:
declare an ado.net connection, and a variable named @rows.  at the end of your delete statement, assign the @@ROWCOUNT variable to your @rows SSIS variable....thats all there is to it.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Have your stored procedure output a value either by an output parameter or a scalar value.
I think there is a server variable for this - might be something like @@RowCount
CERTIFIED EXPERT
Awarded 2008
Awarded 2008
Commented:

Commented:
If you use SQL Task of SSIS, I suggest you to use an output parameter inside Stored Procedure ti send to the SSIS Package the number of rows deleted.
Helped? Regards,
Pedro
www.pedrocgd.blogspot.com
Jim HornSQL Server Data Dude
CERTIFIED EXPERT
Most Valuable Expert 2013
Author of the Year 2015

Author

Commented:
Used this, and replaced the SCOPE_IDENTITY of the insert with @@ROWCOUNT
http://blogs.techrepublic.com.com/datacenter/?p=237

SELECT CAST(@@ROWCOUNT as INT) as foo
Then set the 1st result name to my variable.

Thanks.
Jim
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.