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)
 Turn the tables

Author  Topic 

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2004-10-11 : 05:44:03
Can you pass a recordset/table function/Select statement results into a stored procedure?

I want to write a stored procedure that will work on a set of records. So what I want is something like this

CREATE PROCEDURE my_sp
@Input
SETOFRECORDS
-- this is the bit I am unsure about
AS
UPDATE myTable SET myField = Value Where MyOtherField in (SELECT YetAnotherField from @INTPUT)

Is this possible? Should I use a temp table? Is there not a better way?

thanks

steve




To alcohol ! The cause of - and solution to - all of life's problems

robvolk
Most Valuable Yak

15732 Posts

Posted - 2004-10-11 : 06:35:56
I'd say yes, create a temp table and let the procedure work on that temp table. That will cause you the least amount of grief.
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2004-10-11 : 06:49:42
Thanks, I think I was leaning that way but thought there may be a more elegant solution

steve



To alcohol ! The cause of - and solution to - all of life's problems
Go to Top of Page
   

- Advertisement -