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

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Robin Boyd (none_at_nowhere.com)
Date: 07/14/04


Date: Wed, 14 Jul 2004 17:02:20 +0200

Hi,

I need to exoprt alL the fields that have been modifed to the XML document,
I was going to compare the fields in the "inserted" table with fields in the
"deleted" table (for updates), and then only export the fields that had been
modified. The project is on hold now, so at least Im not loosing any sleep
over how to get the values of the fields into variables!

This is simple to do if I hard code each field and the structure of the
table does not change, as this is an implentation for a customer, I wanted
to 'future-proof' the solution.

I still think there must be some way to accomplish this, allmost every other
DBS system I've used ables you to do this is some form, the easiest I have
ever seen was in Foxpro (V 2.6) "scatter memvar" :)

If anyone has any ideas on this I'd still be pleased to have them!

Thanks all
Robin Boyd

"Tom Moreau" <tom@dont.spam.me.cips.ca> wrote in message
news:u3u63CaaEHA.712@TK2MSFTNGP11.phx.gbl...
> I think Mischa covered it well. BTW, performance is not something you
think
> about "later". It must be a fundamental part of your deisgn.
>
> BTW, I'm more curious about the requirement. it appear you loop through
> each column of each updated row. Is there a technical reason for that?
>
> --
> Tom
> -------------------------------------------------------------------------
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON Canada
> www.pinnaclepublishing.com/sql
>
> "Robin Boyd" <none@nowhere.com> wrote in message
> news:cd2lan$ot8$1@ork.noris.net...
> Hi Mischa,
>
> that hurts, I think a new strategy is required, I really don't like the
idea
> of a large code block in the execute statemant!
>
> Thanks for your input.
>
> Robin
>
> "Mischa Sandberg" <mischa_sandberg@telus.net> wrote in message
> news:lo1Jc.43491$Rf.12075@edtnps84...
> > :-) 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
> > >
> > >
> >
> >
>
>
>



Relevant Pages

  • Re: Batches
    ... ExecuteNonQuery will send the string as is, ... execute the commands, but end effect is the same. ... command, and you do ExecuteNonQuery of that string, you will see one batch submitted to SQL Server. ...
    (microsoft.public.sqlserver.programming)
  • Re: integrated Secure
    ... >I want to set integrated Secure in my connect string to SQL Server ... > But when I execute my web application, it result an error at line: ... > The error message is 'NT AUTHORITY\NETWORK SERVICE' ...
    (microsoft.public.dotnet.framework.adonet)
  • integrated Secure
    ... I want to set integrated Secure in my connect string to SQL Server ... But when I execute my web application, it result an error at line: ...
    (microsoft.public.dotnet.framework.adonet)
  • RE: Syntax Error in Line 1 of Stored Procedure
    ... CommandType to Stored Proc: ... > insert a record into a SQL Server 2000 database table. ... I can execute the procedure without difficulty in SQL ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: stored proc error - ADO and DB2
    ... >> I am VERY new to DB2 but not Orable, Sybase and SQL Server. ... > As I was saying, when I try to execute my stored proc, I get the following ... > String) As String ... > Dim cmd As New ADODB.Command ...
    (microsoft.public.data.oledb)