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 |
|
riadeasleh
Starting Member
8 Posts |
Posted - 2011-09-19 : 08:02:35
|
| Is there a way to select * from table into a cursor.or if there any object that I can use in store procedure similar to the recordset.ThanksRiyd |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-19 : 08:04:19
|
| can i ask why you need row by row iteration? why cant your scenario be implemented by set based solution approach? Probably you could give an explanation on what you're trying to achieve with some sample data and required output------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
riadeasleh
Starting Member
8 Posts |
Posted - 2011-09-19 : 08:39:36
|
| it's because I want to read data based on column index and row indexthe table has a lot of columns,it will make my work a lot eaiser of I could dump the select statement into recordset object if any in sql server 2008, otherewise I will be ending up with a lot of if statements.Thanks Ryid |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-19 : 09:17:57
|
| no need of if statements and row index and column index. i feel like its just a matter of dumping it to some table and doing set based processing------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2011-09-19 : 09:19:42
|
| Hello Ryid,A cursor approach will require you to define a variable for each of the fields you wish to examine in the recordset and then iterate over that dataset evaluating each of the fields.As you may know, SQL Server is not optimized for iterative approaches to data manipulation. It is very powerful at processing set of data.Set-based logic is very different than looping. As visakh16 mentions, there are often more elegant (and much more optimized) approaches to processing sets of data using a 'set-based' approach.You can surely accomplish your need using a cursor, but if you are interested in considering a set-based approach for your need, please post a sample dataset and the desired output and folks here will provide some ideas for set-based solutions.HTH. |
 |
|
|
riadeasleh
Starting Member
8 Posts |
Posted - 2011-09-19 : 09:48:45
|
| Thanks |
 |
|
|
|
|
|