Re: Dynamically selected columns with column switch option

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: DC (dc_at_upsize.de)
Date: 02/28/05


Date: 28 Feb 2005 00:32:34 -0800


"--CELKO--" <jcelko212@earthlink.net> wrote in message news:<1109427772.910829.104260@g14g2000cwa.googlegroups.com>...

> They would avoid dynamic SQL and do the order of presentation of the
> columns in the front end. I have become a fan of the idea that one
> team in the shop handles the database and writes all the SQL for
> everyone, and the application developers make requests to that team.

Two good advises which collide with out original requirements (which
we are about to change though). This is a typical scenario that I am
facing more often so it might be worth to bring it up again:

- Our application provides XML data directly to consumers using FOR
XML clauses.

- There are just about ten stored procs to retrieve this data (like a
search proc, a proc that returns top x results from a predefined
list...) but each proc can return data from about 80 columns (some of
them derived).

- In some cases the comsumer might just require one output column, at
other times 40 different output columns. To keep this as flexible as
possible and to minimize the size of the returned xml structures, we
have decided to provide a web user interface where the comsumer can
enter the required columns and give this set of columns a name which
the middle tier passes to the stored procs.

- This has worked fine so far but as you can see from my previous
posts we are now in the middle of "dynamic sql hell" since our
requirements expanded.

So we are facing a design problem here. The conclusion from your post
- if I get the idea right - is that we "normalize" our requirements
and make a limited amount of "column sets" available directly through
the stored proc, which will be designed by the sql team and on request
they might have to add new requests with new column sets.

The tradeoff is, that the consumers won't be able to perfectly suite
their "column sets" to their requirements, they will have to look for
a predefined set and receive unused columns (and consume additional
bandwith which they pay for). Or they will ask out sql team to
specifically suite a stored proc for their requirement and pay for the
development time.

Another option is to place the "column select" logic into the middle
tier and have sql server typically select a broad range of columns and
pick the ones required in the middle tier. However, these relatively
broad SELECT statements will force the sql server to produce huge
resultsets and one of our initial design requirements was to limit the
sql server output bandwidth where possible.

So in essence we are trading good design vs. sql server output
bandwidth. I am posting this lengthy statement hoping for some rule of
thumb on how to weight these requirements.



Relevant Pages

  • Re: is WITH ENCRYPTION now safe in SQL2005?
    ... > There are very dissenting opinions on that in the SQL Server community. ... > for one reason or another do not get good support from the vendor. ... How would a safe encryption method be implemented? ... about disassemled stored procs from firebird. ...
    (comp.databases.ms-sqlserver)
  • Re: Encrypting SQL objects
    ... objects, i.e. Stored procs, Views, triggers. ... engine must be able to read the source code at run to be able to compile ... And if SQL Server has access to it, ...
    (microsoft.public.sqlserver.security)
  • ADO error handling when connecting to SQL Server 2000
    ... I use Delphi to connect to SQL Server 2000 using the ADO components. ... executing stored procedure that makes some calls to another stored procs. ...
    (microsoft.public.sqlserver.programming)
  • Re: is WITH ENCRYPTION now safe in SQL2005?
    ... > Yes, i know, i don't like extended stored procs too, but i know no other ... In older versions of SQL Server, SQL Server did in fact stored some sort ... of "object code" in sysprocedures. ... the old arrangement and the final result is a cleaner architecture. ...
    (comp.databases.ms-sqlserver)