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
 Transact-SQL (2000)
 pelase solve this issue

Author  Topic 

dasu
Posting Yak Master

104 Posts

Posted - 2004-08-17 : 02:20:26
when ever im trying to execute this stored procedure iam getting error like undeclare cnt variable
plese suggest solution
"
alter proc das_ee @tn varchar(40)
as
declare
@cnt varchar(30),
@q varchar(400)
set @q='select @cnt= count(*) from '+ @tn
exec (@q)
--print (@cnt)

exec das_ee 'test'"

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2004-08-17 : 03:36:38
Your variables aren't in scope when you execute your dynamic sql.

Have a read of these :

http://www.sqlteam.com/item.asp?ItemID=4599
http://www.sqlteam.com/item.asp?ItemID=4619



Damian
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2004-08-17 : 03:48:20
This is a cross post:

http://www.sqlteam.com/Forums/topic.asp?TOPIC_ID=38684


Duane.
Go to Top of Page
   

- Advertisement -