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)
 [RESOLVED] - UDF with Cursor

Author  Topic 

mickey_pt
Starting Member

6 Posts

Posted - 2010-07-19 : 05:55:13
Hello

Need help with one situation...

I have a UDF that returns a datatable, inside this function i have two cursors, the first one it's a simple select that returns a value, then i check if the value it's greater than one, if it's not i just call a insert, if it's greater then i need to create another cursor that needs to return much rows like the value returned by the first one.

In normal conditions the SELECT TOP was the way to go, but i can't use vars with TOP, so i thought that i can use the SET ROWCOUNT before the Cursor, but this doesn't work... Error message: "invalid use of side-effecting or time-dependent operator in 'SET ROW COUNT' within a function"

It's not possible to use the ROWCOUNT inside a UDF?

New one :)

mickey_pt
Starting Member

6 Posts

Posted - 2010-07-19 : 07:11:35
I solved this with a auxiliary var that i increment inside the cursor, and exit when it reaches the limit.

-> WHILE @@FETCH_STATUS = 0 AND @NumberRow <= @Limit


New one :)
Go to Top of Page
   

- Advertisement -