On Wed, Jan 19, 2011 at 4:07 PM, Lou Syracuse <[email protected]> wrote:
> Ok it doesn't exist as we know it in VFP, but there has to be a way to do
> something like this.  I have a variable that has the name of a field in it.
> I want to retrieve the value of that field from a table
>
>
>
> Something like:
>
>
>
> Declare @vCol2Use as char(10)
>
> Declare @MyValue  as integer
>
> Set @vCol2use = 'RESP01'
>
> Set @MyValue = (Select &@Myvalue from mydatatable)
>

> The values for @vCol2use go up to RESP80.   This is already the storedproc
> from h3ll, there has to be a way to not hand-code a block of 80 case
> statements.    I am converting a VFP program to a SQL call in preparation
> for our SQL update, and have been reminded how cool some of the string
> manipulation and database functions are in VFP.
--------------------

Not really.

You will have to define a STRING and populate the STRING not just copy
the text to a string.  This means datetime values need to be converted
for use and you preface them with a ' and then terminate with the ' as
well.  :)

Try this site for a good overall method:
<http://www.dba-sql-server.com/sql_server_tips/t_super_sql_460_dynamic_sql.htm>

I have done this in SPs before, well really I manufactured a statement
via cursor metadata.  Shoot me now for even thinking of it. PLEASE!

What are your case statements?  that # you stat seems real high but
you cold be in ETL hell and you just live with it.


-- 
Stephen Russell

Sr. Production Systems Programmer
CIMSgts

901.246-0159 cell

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to