dbTalk Databases Forums  

Error--Update Staement

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Error--Update Staement in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Steve
 
Posts: n/a

Default Error--Update Staement - 11-05-2004 , 03:29 PM







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

Steve

Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Error--Update Staement - 11-06-2004 , 02:18 AM






You cannot use variables like this. If you want to do this then consider
using

1. Dynamic SQL

http://www.sommarskog.se/

2. DTS and the object model

Global Variables and SQL statements in DTS
(http://www.sqldts.com/default.aspx?205)

--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.konesans.com - Consultancy from the people who know


"Steve" <Steve (AT) discussions (DOT) microsoft.com> wrote

Quote:
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

Steve



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.