|
|
Question : exec(<string>) & cursor in SQL6.5
|
|
Hi
I'm trying to use exec() in MS-SQL server 6.5 but I've stumbled into some problems. I want to access the rowset created by the or at least the value of the @@RowCount variable (in context of the procedure _calling_ exec). Is there any way to do this?
The SQL server books online, Transact sql reference on cursors states: "Cursors are extremely powerful when combined with stored procedures and the EXECUTE statement (to dynamically build strings)."
How? I've attached a piece of code that describes what I want to do. I get the error "Incorrect syntax near the keyword 'exec'."
/Klas ---
CREATE PROCEDURE foo @constraint varchar(50) AS
DECLARE @bar varchar(50)
DECLARE cuFoo SCROLL CURSOR FOR exec('SELECT bar FROM fooTable where '+@constraint) OPEN cuFoo FETCH NEXT FROM cuFoo INTO @bar
WHILE (@@FETCH_STATUS = 0) BEGIN select 'a bar value:' + @bar FETCH NEXT FROM cuFoo INTO @bar END
CLOSE cuFoo DEALLOCATE cuFoo
GO
|
Answer : exec(<string>) & cursor in SQL6.5
|
|
Answer as Below
Cheers
|
|
|
|
|