Re: how to assign the contents of a field to a variable

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Aaron [SQL Server MVP] (ten.xoc_at_dnartreb.noraa)
Date: 07/13/04


Date: Tue, 13 Jul 2004 10:38:49 -0400

http://www.aspfaq.com/2492

-- 
http://www.aspfaq.com/
(Reverse address to reply.)
"Robin Boyd" <none@nowhere.com> wrote in message
news:cd0rpp$1ni$1@ork.noris.net...
> Hi all,
>
> I am trying to assing the value of a field (stored in a variable) to
another
> variable.  I have tried various approaches with no success :(
>
> here is the code I am working with...
>
> --SELECT@CurrFieldValue = CustomerID FROM[Inserted]
> SET @MySQL = 'SELECT @CurrFieldValue = ' + @CurrFieldName + ' FROM
> [Inserted]'
> EXECUTE @MySQL
>
>
> I currently get the following error message:
> The name 'SELECT @CurrFieldValue = CustomerID FROM [Inserted]' is not a
> valid identifier.
>
> The commented lien works perfectly, however as I execute this code from
> within a loop (for all the fields in the table) this is no good.
>
> Any help, pointers or such, most welcome!
>
> Thanks in advance,
> Robin Boyd
>
>


Relevant Pages