February 8, 2019 at 2:19 pm
How can I query for when a bulk insert was started, ended and record count inserted ?
I have searched the web but all I get is information on how to use bulk insert and why it shouldn't be used. I have no say in that, as it is part of an application, I just need to provide the previously stated data.
Thanks.
February 8, 2019 at 2:37 pm
Budd - Friday, February 8, 2019 2:19 PMHow can I query for when a bulk insert was started, ended and record count inserted ?
I have searched the web but all I get is information on how to use bulk insert and why it shouldn't be used. I have no say in that, as it is part of an application, I just need to provide the previously stated data.
Thanks.
It's pretty much like anything else you can do in a quey... Set a variable for the start date/time before you call it. Immediately after the call, select from @@ROWCOUNT to get the rows affected and subtract the start date/time from the current date time to get the duration.
Would love to see some of the articles you found why BULK INSERT shouldn't be used. Got any links in particular?
--Jeff Moden
Change is inevitable... Change for the better is not.
February 8, 2019 at 3:01 pm
Jeff Moden - Friday, February 8, 2019 2:37 PMIt's pretty much like anything else you can do in a quey... Set a variable for the start date/time before you call it. Immediately after the call, select from @@ROWCOUNT to get the rows affected and subtract the start date/time from the current date time to get the duration.Would love to see some of the articles you found why BULK INSERT shouldn't be used. Got any links in particular?
I was curious about articles saying why bulk insert shouldn't be used. I found one related to Entity Framework but it's EF with all of their issues so I ignored it.
Otherwise the ones I found were related to security risks. I'd love to see any others. Here is one typical of some of the posts and concerns about security:
Why is BULK INSERT Considered Dangerous?
That's the gist of it from what I could find. And standing up any database server is a security risk. So we need to stop doing that.
Sue
February 8, 2019 at 3:55 pm
Sue_H - Friday, February 8, 2019 3:01 PMJeff Moden - Friday, February 8, 2019 2:37 PMIt's pretty much like anything else you can do in a quey... Set a variable for the start date/time before you call it. Immediately after the call, select from @@ROWCOUNT to get the rows affected and subtract the start date/time from the current date time to get the duration.Would love to see some of the articles you found why BULK INSERT shouldn't be used. Got any links in particular?
I was curious about articles saying why bulk insert shouldn't be used. I found one related to Entity Framework but it's EF with all of their issues so I ignored it.
Otherwise the ones I found were related to security risks. I'd love to see any others. Here is one typical of some of the posts and concerns about security:
Why is BULK INSERT Considered Dangerous?That's the gist of it from what I could find. And standing up any database server is a security risk. So we need to stop doing that.
Sue
Thanks, Sue. It's amazing with what people on threads like that come up with.
--Jeff Moden
Change is inevitable... Change for the better is not.
February 11, 2019 at 6:10 am
Jeff Moden - Friday, February 8, 2019 2:37 PMBudd - Friday, February 8, 2019 2:19 PMHow can I query for when a bulk insert was started, ended and record count inserted ?
I have searched the web but all I get is information on how to use bulk insert and why it shouldn't be used. I have no say in that, as it is part of an application, I just need to provide the previously stated data.
Thanks.It's pretty much like anything else you can do in a quey... Set a variable for the start date/time before you call it. Immediately after the call, select from @@ROWCOUNT to get the rows affected and subtract the start date/time from the current date time to get the duration.
Would love to see some of the articles you found why BULK INSERT shouldn't be used. Got any links in particular?
I didn't save any links about why bulk insert should not be used, and my statement was too general. Most of what I was referring to in my initial post had to do with security permissions required.
As for your suggestion of capturing @@ROWCOUNT; I'm not sure how I can do that, as I said the BULK INSERT is call from within the application code. Can you explain, please ?
February 11, 2019 at 6:47 am
Budd - Monday, February 11, 2019 6:10 AMJeff Moden - Friday, February 8, 2019 2:37 PMBudd - Friday, February 8, 2019 2:19 PMHow can I query for when a bulk insert was started, ended and record count inserted ?
I have searched the web but all I get is information on how to use bulk insert and why it shouldn't be used. I have no say in that, as it is part of an application, I just need to provide the previously stated data.
Thanks.It's pretty much like anything else you can do in a quey... Set a variable for the start date/time before you call it. Immediately after the call, select from @@ROWCOUNT to get the rows affected and subtract the start date/time from the current date time to get the duration.
Would love to see some of the articles you found why BULK INSERT shouldn't be used. Got any links in particular?
I didn't save any links about why bulk insert should not be used, and my statement was too general. Most of what I was referring to in my initial post had to do with security permissions required.
As for your suggestion of capturing @@ROWCOUNT; I'm not sure how I can do that, as I said the BULK INSERT is call from within the application code. Can you explain, please ?
I think that in order to make it absolutely clear that you should tell us exactly how your "bulk insert" is done.
and is it really T-SQL bulk insert statement or bcp, or oledb/ado.net bulk insert object
code sample might be the best, full snippet, not just the bulk insert itself.
February 11, 2019 at 7:37 am
I understand that would be the best way to do this, however, I can't do that. Let me try to rephrase my question.
Are there any system tables that capture bulk insert transactions ?
February 11, 2019 at 7:53 am
Budd - Monday, February 11, 2019 7:37 AMI understand that would be the best way to do this, however, I can't do that. Let me try to rephrase my question.
Are there any system tables that capture bulk insert transactions ?
To the best of my knowledge, there's nothing intrinsic to monitor for such things except maybe the default trace, which is unreliable on a busy system because of the quick rollover of the logs. I wouldn't know how to do it but I believe that Extended Events could be set up to monitor for such transactions.
--Jeff Moden
Change is inevitable... Change for the better is not.
February 11, 2019 at 8:02 am
Thanks Steve, Extended Events is what I just started looking into.
February 11, 2019 at 8:06 am
Budd - Monday, February 11, 2019 8:02 AMThanks Steve, Extended Events is what I just started looking into.
Depending on what you want to track, you may want to check the extended event: database_bulk_insert_rows
Sue
February 11, 2019 at 9:32 am
Thank you Sue. I don't see that in SSMS 2017 on SQL 2016Ent.
February 11, 2019 at 10:17 am
Budd - Monday, February 11, 2019 9:32 AMThank you Sue. I don't see that in SSMS 2017 on SQL 2016Ent.
Start a new Events session and for the event, just type in bulk and you will see the events for bulk insert.
Sue
February 11, 2019 at 10:32 am
That I do see, actually I see it in the Template selection list under new session wizzard.
Thank you.
Viewing 13 posts - 1 through 12 (of 12 total)
You must be logged in to reply to this topic. Login to reply