solving sql server problems for millions of dbas and developers since 2006



SQL Server DBA Tips SQL Server Developer Tips SQL Server Business Intelligence Tips SQL Server Career Tips SQL Server Whitepapers SQL Server Tools SQL Server Webcasts SQL Server Questions and Answers SQL Server Questions and Answers













Excel Functions inTSQL

Asked 2/9/2012 7:51:51 AM by Femi Adeniyi

Hi All,

 

I guess it is possible to use any of the Excel functions within TSQL stored procedures?

 

Please can someone show me how with an example calculating YIELD(settlement,maturity,rate,pr,redemption,frequency,basis)

Thanks in advance

 

Femi



Answered 2/9/2012 9:42:21 AM by Scott C (0) vote answer is useful vote answer is NOT useful

You can't use Excel functions directly in TSQL, at least not in any reasonable fashion.

In theory, you might be able to invoke an instance of Excel with object automation, set up a worksheet with the function, populate it with data, retrieve the result and return that from a stored procedure.  But I doubt any sane DBA would let you put that mess on a production server.  What if there are multiple calls to this function, how many Excel processes do you want to have on your SQL Server at one time?

You could create a spreadsheet in Excel that loads data from SQL Server, and stores the results back to SQL Server.  The Excel process is on the client where it should be.

The best solution (for running in SQL Server) would be to find a definition for the algorithm behind the YIELD function and code it in T-SQL, or in a CLR function.



Post an Answer

Keep it clean and stay on the subject or we may delete your comment.
Your email address is not published. Required fields are marked with an asterisk (*)

*Name   *Email   Notify for updates
Comments
*Enter Code refresh code


 
Sponsor Information
Try the free performance monitoring tool from Idera!

The 10 tools in the SQL Developer Bundle cut the time spent in dull and tedious tasks. Learn more.

Need SQL Server help and not sure where to turn? Reach out to the Edgewood experts for a Health Check starting at $995.

Find and Fix SQL issues with Foglight Performance Analysis. Get a free copy.

Join the over million SQL Server Professionals who get their issues resolved daily.

The SQL Server Security THREAT - It’s Closer Than You Think


Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved
privacy | disclaimer | copyright | advertise | about
authors | contribute | feedback | giveaways | user groups
Some names and products listed are the registered trademarks of their respective owners.


Edgewood Solutions LLC | MSSharePointTips.com | MSSQLTips.com