hi this is kavita I am creating a procedure like:
alter proc insert_tmpsearch1now
@var4 varchar(50)
as
select @var4='select top 10 * from activetable'
DECLARE @var1 VARCHAR(50),@var2 VARCHAR(50),@var3 VARCHAR(200)
DECLARE CUR CURSOR FOR select top 10 * from activetable
OPEN CUR
FETCH NEXT FROM CUR INTO @var1,@var2,@var3
WHILE @@FETCH_STATUS = 0
BEGIN
print execute(@var4)
insert into tmpsearch1now(ssid,ref_no,sr_no,detail) values('4',@var1,@var2,@var3)
FETCH NEXT FROM CUR INTO @var1,@var2,@var3
END
CLOSE CUR
DEALLOCATE CUR
go
it work fine but I want to pass a variable say @var4 in declare cursor line like this
DECLARE CUR CURSOR FOR execute(@var4)
but it gave some error How can I do this?
please help!!!