Re: Error--Update Staement
From: Steve (Steve_at_discussions.microsoft.com)
Date: 11/05/04
- Next message: Mike John: "Re: Insert with response"
- Previous message: Hugo Kornelis: "Re: Covering indexes versus column order in Delaney"
- In reply to: Aaron [SQL Server MVP]: "Re: Error--Update Staement"
- Next in thread: Armando Prato: "Re: Error--Update Staement"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 5 Nov 2004 14:26:02 -0800
Thanks :)
"Aaron [SQL Server MVP]" wrote:
> You've declared @a as a variable, then you are trying to run an update
> statement against that variable. UPDATE statements cannot apply to
> variables, but I think you can do what you are trying to do using dynamic
> SQL.
>
> http://www.sommarskog.se/dynamic_sql.html
>
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
>
>
> "Steve" <Steve@discussions.microsoft.com> wrote in message
> news:0FD7AEDA-8FA7-4C45-BE48-15E9D4A4F114@microsoft.com...
> > Hi,
> > I am getting error when I run the following statement
> >
> >
> >
> >
> > declare @a nvarchar(255)
> > select @a = tblname from logtbl where tblname like 'orders%'
> > and logtbl.logdate > getdate() - .5
> >
> > update @a
> > set @a.log_id = l.log_id
> > from @a , logtbl l
> > where l.logdate > getdate() - .5
> > l.tblname like 'orders%'
> >
> >
> > Server: Msg 137, Level 15, State 2
> > Must declare the variable '@a'.
> >
> > Plz.help
>
>
>
- Next message: Mike John: "Re: Insert with response"
- Previous message: Hugo Kornelis: "Re: Covering indexes versus column order in Delaney"
- In reply to: Aaron [SQL Server MVP]: "Re: Error--Update Staement"
- Next in thread: Armando Prato: "Re: Error--Update Staement"
- Messages sorted by: [ date ] [ thread ]