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 |
|
elwoos
Master Smack Fu Yak Hacker
2052 Posts |
Posted - 2004-09-01 : 08:44:17
|
| I know I shouldn't be using cursors if I can avoid it but I'm not sure what the alternative is so would be interested in what people think. My scenario is this. I have a stored procedure that will put a single record into a table (with the values passed to it as parameters - no table parameters as we are using SQL Server 7). I have to use this sproc. What I want to do is to put multiple records (i.e. a recordset containing 0 or more records) into the table. How do I do it without using cursors?steveSteve no function beer well without |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2004-09-01 : 08:50:38
|
| I guess to me the question becomes why do you have to use that specific sproc?Corey |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-09-01 : 08:53:11
|
| you need to be more specific, with an example. re-read your question, pretend you are not familiar with the situation, and you'll notice it gives no specific information at all about what you are trying to accomplish.- Jeff |
 |
|
|
elwoos
Master Smack Fu Yak Hacker
2052 Posts |
Posted - 2004-09-01 : 09:23:39
|
| OK here goes. The sproc will return the ID of the record and I need to make use of that.lets say the sproc is called sproc_insert_record and takes parameters @FirstName and @LastName so exec sproc_insert_record 'Joe', 'bloggs' will create a single record for Joe Bloggs in the table People and will return his primary key which I will then use elsewhere.I will be receiving a dataset of unknown length i.e 0 or more records that I want to put into my People table. The dataset will be arriving in a holding table on an irregular basis. So for example, on one occasion it may contain the following recordsFred BloggsJoe JonesMicky Mouseand on another it may contain nothing (I want to run this process as a job on a regular basis, e.g. every half hour) so that the data in the holding table is put into the People tableHope this is clearersteveSteve no function beer well without |
 |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2004-09-01 : 09:29:34
|
| So the only reason you want to use the sproc is to make use of he id returned??What do you need to do with the id?? What you are trying to do with the id may determine how you have to approach it. Could you join with the holding table and the peoples table to get the ids of the people you added??You could always just have that query do a loop through all of the records in the table. It would be less costly than a cursor, but its the same concept.Corey |
 |
|
|
|
|
|