Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Exec statement

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-04-05 : 08:12:09
venkat writes "When I try to execute this SP, I get the error "Must declare the variable '@return'."

This SP compiles without errors, but while executing I get this error.
The thing is that I am framing a string and dynamically executing thru exec stmt.

can any one throw any ideas on this ..


create proc test
as
begin
declare @string varchar(100)
DECLARE @return varchar(100)

select @string = 'exec test1 @return output'
print @string
EXEC (@string)
end"

ijprasad
Starting Member

29 Posts

Posted - 2005-04-05 : 08:39:13
the datatype @return defined outside the batch execution from @string values, Hence it gives error

Try this


create proc test
as
begin
declare @string varchar(100)
select @string = ' DECLARE @return varchar(100) '
+ ' exec test1 @return output'
print @string
EXEC (@string)
end

Inderjeet
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-04-05 : 10:16:09
http://sqlteam.com/forums/topic.asp?TOPIC_ID=47911

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -