You are here: Re: How to build a procedure that returns different numbers of columns as a result based on a parameter « MsSQL Server « IT news, forums, messages
Re: How to build a procedure that returns different numbers of columns as a result based on a parameter

Posted by Hugo Kornelis on 11/23/06 23:24

On Thu, 23 Nov 2006 13:29:02 -0500, serge wrote:

(snip)
>We would like to know what you think of this approach
>and if you know a simpler way of doing it.

Hi Serge,

First: thanks for posting the necessary SQL statements to recreate your
situation on our computers.

To your question: if you need to return different sets of columns under
different circumstances, I'd use different stored procedures for each
result set. The use of dynamic SQL as in your example has some downsides
and some risks that you should avoid if at all possible.

See http://www.sommarskog.se/dynamic_sql.html

--
Hugo Kornelis, SQL Server MVP

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация