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
 SQL Server Development (2000)
 Stored Procedure (insert based on selected values)

Author  Topic 

zippy
Yak Posting Veteran

69 Posts

Posted - 2001-09-24 : 07:12:59
Hi,
I am trying to write a stored procedure which will query my database based on a value I input.
If a recordset is returned I want it to add one of the values with another value that is inputed(?) and then update it.
If no recordset is returned I want it to insert a new row in the table with the values given.
ie.
Input values:
PersonID
NumberResults

if rs.eof
insert blah blah blah
else
updaate blah blah blah

I know how to insert data to the sp and manipulate it with if else etc. but what I don't know is how to deal with returning a recordset inside the sp, how is the data handled? how do you put it into a variable? how do you add values? etc.

Can anyone enlighten me on this?

Thanks a bunch



Check out the worlds fastest computers at http://www.ocgurus.com

dogli
Starting Member

32 Posts

Posted - 2002-12-06 : 16:52:11
Hi Zippy,

I know this is a very old topic. But I have the same problems as you have met before. Can you tell me what's article?

What I want to do is query a table, and then store some of the record in local variable, and use these varibale in other queries in the same stored procedure.

Can anybody give me some ideas?

I really appreciate your help!

Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2002-12-07 : 10:47:52
Examples on how to pass parameters to stored procedure using ado command object

http://www.flws.com.au/showusyourcode/codeLib/code/ADOCommand.asp?catID=3
http://www.geocities.com/priyadarshu/tech/Ado_vb.htm

Example of stored procedure and passing parameters
http://www.sqlteam.com/item.asp?ItemID=2755

Example of how to query and keep information in temp table and table variable
http://www.sqlteam.com/item.asp?ItemID=436
http://www.sqlteam.com/item.asp?ItemID=9454

Go to Top of Page
   

- Advertisement -