Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 1234»»»

Writing to a File Using the sp_OACreate Stored Procedure and OSQL: The Expand / Collapse
Author
Message
Posted Thursday, January 20, 2005 12:40 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, July 2, 2012 9:31 AM
Points: 65, Visits: 46
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/zNichter/writingtoafileusingthesp_oacreatestoredprocedurean.asp



--------------------------
Zach

Odds_And_Ends Blog
Post #156796
Posted Monday, February 7, 2005 3:51 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, June 24, 2014 9:21 AM
Points: 100, Visits: 182
Excellent article.
It's always useful to know just how the server performs under different situations.
I tend to use Perl with a pipe from OSQL to access data exported from the SQL server (which allows filtering/formatting on the fly if necessary) as a default method of handling data output to a file.
There have been times when I've been tempted to keep the file writing on the server side, to aid reliability of write for certain actions, but this article will definitely make me think twice before using the SP methods for file creation.

Thanks for a good read!
Post #159965
Posted Monday, February 7, 2005 6:41 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, September 4, 2014 9:46 AM
Points: 295, Visits: 280

I would generally pump the performance data to a table. This allows a lot more flexibility in the reporting. If you need some kind of report you can use a reporting package or even just DTS it out to a text file.

Your article had an excellent conclusion. Based on it's title, I really expected a pro-sp_OAx article but was very pleasantly suprised. It's great to see someone taking time out to make decisions based on solid data and I think this sets an excellent example for the novices that come here to learn.

Kudos!



Bryant E. Byrd, BSSE MCDBA MCAD
Business Intelligence Administrator
MSBI Administration Blog
Post #160004
Posted Monday, February 7, 2005 10:31 AM


Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, November 12, 2007 6:32 AM
Points: 62, Visits: 3

Nice article, thanks for sharing your research!

 

Post #160097
Posted Monday, February 7, 2005 10:18 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 2:33 PM
Points: 37,075, Visits: 31,633

Very Nice article.  Covered a lot of ground and it's a pleasure to actually see commented formatted code.  I've seen a method to write to text files using linked servers through the use of a file called Schema.ini (I think that's what it's called).  Sure would be nice to see a follow-up article on that.

Like someone said before me, "Thanks for sharing your research!"



--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #160184
Posted Tuesday, February 8, 2005 8:40 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, July 2, 2012 9:31 AM
Points: 65, Visits: 46
Thanks for all of the responces on the article. I'll have to look into the schema.ini option I'll let you know if I find anything out on it.

I wish I knew Perl, I've been wanting to pick up book on it for some time but have never gotten around to it.

Thanks Again,
Zach




--------------------------
Zach

Odds_And_Ends Blog
Post #160282
Posted Tuesday, February 7, 2006 6:14 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, July 22, 2010 8:59 AM
Points: 110, Visits: 952
Where was the example using bcp or DTS?

If you're going to use a hammer to drive a screw, be thorough enough to examine the rest of the non-screwdriver solutions.
Post #256338
Posted Tuesday, February 7, 2006 6:45 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, January 13, 2011 6:04 AM
Points: 37, Visits: 323

I agree that it is too bad that you did not include bcp and DTS in your analysis. For a simple write to file, though, DTS seems hardly appropriate. And when you're trying avoid the dreaded xp_cmdshell in a user application, then the cost xp_OACreate is much more tolerable. However, I never realized how big of a cost xp_OACreate was. Thanks for the article!

Post #256346
Posted Tuesday, February 7, 2006 7:52 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, July 2, 2012 9:31 AM
Points: 65, Visits: 46

Mike, thanks for the responce.  The goal of the article was more to identify the performance factor involved in the use of the sp_oa extended procs and using it and other meathods through Query analyzer to identify the overhead associated to them.  But you are right though, bcp is a much better option, and as for DTS, it really didn't fit the need of the situation that I was in.  Maybe you should consider contributing to the community yourself sometime, it might make you a little less grumpy...

Oh and thanks for the comments Charles.





--------------------------
Zach

Odds_And_Ends Blog
Post #256401
Posted Tuesday, February 7, 2006 8:51 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Saturday, October 12, 2013 10:42 PM
Points: 263, Visits: 297

I believe this was an unfair comparison against sp_OACreate.

Test2, Test3, and Test4 all open the file first, then write the 100,000 lines, then close the file.

Test5 and Test6 100,000 times does this: creates the object, opens the file, writes a line, and then destroys the object (which I am assuming close the file handle?).

If the same flow (open-write-close) was done on the other files 100k times, I am sure they would seem slower also. A better comparison of sp_OACreate would be to create, open, write 100k, close, then destroy.

But then again it feels like Monday morning... Am I missing something about these tests?

 

Post #256441
« Prev Topic | Next Topic »

Add to briefcase 1234»»»

Permissions Expand / Collapse