Re: Parameterize FROM clause in Stored Procedure: How To?
steve wrote:
The specific situation at hand here is akin to having two tables in
the database called MaleEmployees and FemaleEmployees . You /could/
use table-type variables, but what you really should do instead is
merge both into one table (or view, if you can only fix things one
piece at a time) with a Gender column added.
As previously discussed, I agree that table-type variables would be
useful in other situations, though I still think you're shooting
yourself in the foot by constantly pointing to an instance (Dataphor)
that would incur a huge switchover cost for existing projects. SQL
Server 2008 has table-valued parameters, albeit limited to read-only
input parameters; within that limit, do you approve of them?
steve wrote:
On Oct 17, 12:14 pm, bill <billmacle...@g mail.comwrote:
>
The most fundamental idea of a "relational " database is that a table
is a VARIABLE
and can be passed as a parameter just like a variable defined as an
integer. The concept of a table as a variable does not exist in sql
and users are left to fumble
with dynamic sql as a way to compensate for the lack. Only in an
upside down world could a table as a variable be seen as 'cheesy'. And
if sql is a cheese it must be swiss :)
>
>
www.beyondsql.blogspot.com
>Hi Dan,
>>
>I've been thinking more about this, because I it seems kind of cheesy
>to pass a parameter into the FROM clause.
>.
>>
>I've been thinking more about this, because I it seems kind of cheesy
>to pass a parameter into the FROM clause.
>.
The most fundamental idea of a "relational " database is that a table
is a VARIABLE
and can be passed as a parameter just like a variable defined as an
integer. The concept of a table as a variable does not exist in sql
and users are left to fumble
with dynamic sql as a way to compensate for the lack. Only in an
upside down world could a table as a variable be seen as 'cheesy'. And
if sql is a cheese it must be swiss :)
>
>
www.beyondsql.blogspot.com
the database called MaleEmployees and FemaleEmployees . You /could/
use table-type variables, but what you really should do instead is
merge both into one table (or view, if you can only fix things one
piece at a time) with a Gender column added.
As previously discussed, I agree that table-type variables would be
useful in other situations, though I still think you're shooting
yourself in the foot by constantly pointing to an instance (Dataphor)
that would incur a huge switchover cost for existing projects. SQL
Server 2008 has table-valued parameters, albeit limited to read-only
input parameters; within that limit, do you approve of them?
Comment