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.
| Author |
Topic |
|
jgandara
Starting Member
18 Posts |
Posted - 2006-03-09 : 11:47:29
|
| Instead of havingCreate <CursorName> CURSOR FROM<execute store procedure>Any ideas?, is it possible or not? |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2006-03-09 : 11:56:24
|
| my suggestion is to not use a cursor at all. Use a table variable or a temp table instead.For your specific problem, you could use an intermediate temp table. But that would be very inefficient. -ec |
 |
|
|
jgandara
Starting Member
18 Posts |
Posted - 2006-03-09 : 12:12:22
|
| I already have a store procedure that executes a dynamic SQL statement. I decided to do it dynamic because if a parameter has no value, then it shouldn't be included in the SELECT statement.I have around 9 parameters so it uses a lot of ifs conditions.I'd like to reuse the SP.I need a cursor because I have to use the data to do some other database modifications. I only have a few records so performance wise is not a problem. |
 |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2006-03-09 : 12:21:49
|
quote: Originally posted by jgandara I already have a store procedure that executes a dynamic SQL statement. I decided to do it dynamic because if a parameter has no value, then it shouldn't be included in the SELECT statement.I have around 9 parameters so it uses a lot of ifs conditions.I'd like to reuse the SP.I need a cursor because I have to use the data to do some other database modifications. I only have a few records so performance wise is not a problem.
like I said, use a temp table or a table var instead of a cursor. You can populate those table types from the output of a stored proc.-ec |
 |
|
|
mmarovic
Aged Yak Warrior
518 Posts |
Posted - 2006-03-15 : 17:26:35
|
| If you have just a few rows and you have to use cursor then put sp results in temp table and make cursor on temp table. It awfully slow, but for a few rows it doesn't matter (if not executed frequently) |
 |
|
|
|
|
|