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)
 using Parameterised query in cursor

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-11-16 : 06:50:44
Siva writes "/* In the cursor i want to give sql query as a parameter insteat of giving a direct query

the query i mentioned as @sql but its giving error i tried with sP_executesql also but its giving error
my program i displayed below will anybdy of u please modify this code
and rewrite a correct code or else give a solution to this problem
i used northwind database */
-----------------------------------------------------------------

begin
declare @sql nvarchar(200),@cname nvarchar(200)

set @sql="select CompanyName from customers"
declare cs cursor for @sql
begin
open cs
fetch next from cs into @cname
while @@fetch_status=0
begin
select @cname
end
close cs
deallocate cs
end
end"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-16 : 06:56:45
Explain what you are trying to do
There must be easier way than what you are doing

Madhivanan

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

- Advertisement -