[thelist] SELECT @Variable FROM Table

Luther, Ron Ron.Luther at compaq.com
Fri Jul 27 15:59:36 CDT 2001


Hi Darren | Matt,


I dunno, that looks like a pretty common table structure to me. At least it
seems like I run into those kinds of summary tables quite a bit.  [In fact,
I think it's pretty common to have two of these together - one for the
current year, and a second table for "history" which has a similar structure
except for one extra field (year) that you need to use so you don't comingle
1999 and 1998 data.  Fun, eh?  This lets you write those nice reports that
use six months of data and straddle year boundaries or do 'year over year',
'same qtr over same qtr' comparisons.]

I'm pretty sure the "Select " + variable1 + " from Table where ind = 1"
approach has worked for me using Oracle and Access. (I don't use SQL7 very
often.)

Anyway, another approach would be to "Select * from Table where ind = 1" to
read in teh whole record.  Now that you've pulled in the data, you can use
your server language du jour to pick off the value for the field you are
interested in.


HTH,


RonL.

-----Original Message-----
From: Darren [mailto:Darren at web-bitch.co.uk]
Subject: Re: [thelist] SELECT @Variable FROM Table

After a bit of scrabbling through the BOL I went with the sp_executesql
as it allows a lot more flexibility and you can pass parameters in and
out so no messing around with the second table.




More information about the thelist mailing list