Path: csiph.com!usenet.pasdenom.info!news.albasani.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Erland Sommarskog Newsgroups: comp.databases.ms-sqlserver Subject: Re: help with output parameters needed Date: Thu, 13 Mar 2014 08:40:25 +0100 Organization: Erland Sommarskog Lines: 19 Message-ID: References: <88badd6b-44dc-44ed-81c0-a423f3053ab6@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Injection-Info: mx05.eternal-september.org; posting-host="fd3d6d0229f14a752f017d8f9903addd"; logging-data="13950"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19A3tER4dGvs+CxH6Oq2rex" User-Agent: Xnews/2006.08.24 Mime-proxy/2.1.c.0 (Win32) Cancel-Lock: sha1:ltuuBOQvJFvTRssE81eKKAd4fUk= Xref: csiph.com comp.databases.ms-sqlserver:1729 migurus (migurus@yahoo.com) writes: > My difficulty is that SP can return output parameters, but it seems I > can't call SP in select? The UDF can be called from select but can not > return more than one value and I need to return at least two, in fact 4 > values, I just simplified everything. You can make it a table-valued function that returns a one row result set, and then use cross apply: SELECT .. FROM tbl CROSS APPLY dbo.run(col1, col2) AS run However, as Ross says, it is better if you can implement something that operates on a set of data, taking the input from a table-valued parameter. For large data sets, this could be a dramatic difference in performance. -- Erland Sommarskog, Stockholm, esquel@sommarskog.se