Re: how to assign the contents of a field to a variable
From: Mischa Sandberg (mischa_sandberg_at_telus.net)
Date: 07/14/04
- Next message: Arzan: "Re: Syntax error converting character string to smalldatetime data"
- Previous message: Mischa Sandberg: "Re: Range query optimization help?"
- In reply to: Robin Boyd: "how to assign the contents of a field to a variable"
- Next in thread: Robin Boyd: "Re: how to assign the contents of a field to a variable"
- Reply: Robin Boyd: "Re: how to assign the contents of a field to a variable"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 14 Jul 2004 03:03:45 GMT
:-) Two non-obvious things going wrong here.
(1) You meant EXEC(@MySQL), not EXEC @MySQL.
The first does what you want. The second tries to find a STORED PROC with
the unlikely name of "SELECT @CurrFieldValue = ...".
Hence the 'not valid identifier' error.
(2) Inside and outside EXECUTE(...) are two different scopes.
That means, the @CurrFieldValue you declared in the surround code (proc?)
does not exist, as far as the code inside the EXECUTE() string is concerned.
And, if you declared (and set) @CurrFieldValue in the string, that would
have
no effect on the one declared outside the EXECUTE().
What this means is, you may have to move a hunk more code into the EXEC()
string.
"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
>
>
- Next message: Arzan: "Re: Syntax error converting character string to smalldatetime data"
- Previous message: Mischa Sandberg: "Re: Range query optimization help?"
- In reply to: Robin Boyd: "how to assign the contents of a field to a variable"
- Next in thread: Robin Boyd: "Re: how to assign the contents of a field to a variable"
- Reply: Robin Boyd: "Re: how to assign the contents of a field to a variable"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|