Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Advertise
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 7,2000
»
T-SQL
»
BCP queryout speed
BCP queryout speed
Rate Topic
Display Mode
Topic Options
Author
Message
RD-201664
RD-201664
Posted Wednesday, November 18, 2009 11:47 AM
Grasshopper
Group: General Forum Members
Last Login: Friday, March 12, 2010 11:08 AM
Points: 22,
Visits: 257
Hi,
I have a stored procedure that takes about 10 seconds to run directly on the server in QA. The proc is a series of select statements and only returns about 10 - 20 rows.
If I use this same proc in a BCP queryout command, it takes 2.5 minutes to complete.
sproc command in QA (takes 10 seconds):
exec [MyDB].[dbo].[MySproc]
BCP command (take 2.5 minutes):
declare @sql varchar(200)
select @sql = 'bcp "exec [MyDB].[dbo].[MySproc]" queryout \\server\share\filename.txt -c -T'
exec master..xp_cmdshell @sql
I can see the filename.txt is created immedialtely with 0 bytes. 2.5 minutes later the resutls are written to the file and the file is closed.
Thanks for any help.
When running the BCP command in QA, the output shows:
NULL
Starting copy...
NULL
13 rows copied.
Network packet size (bytes): 4098
Clock Time (ms.): total 10625
NULL
Post #821055
RD-201664
RD-201664
Posted Thursday, November 19, 2009 10:38 AM
Grasshopper
Group: General Forum Members
Last Login: Friday, March 12, 2010 11:08 AM
Points: 22,
Visits: 257
More strange findings when using BCP:
The proc has a cursor. I added an audit log step to the proc so it inserts audit info to another table.
When I run the proc from Query Analyzer it runs as expected and logs data for each step of the cursor as expected.
When I run this using the above BCP command, it writes double records to the audit table:
audit record 1
audit record 2
audit record 1
audit record 2
Post #821795
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2010 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use