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 |
|
george
Starting Member
4 Posts |
Posted - 2009-01-20 : 12:32:18
|
| Hello - I want to execute a stored procedure I have by passing in the values of the result set returned from a select statement.I am doing this right now by using the following codeINSERT INTO LogInsert SELECT id, action from actiontableI really want to clean this up and use a stored procedure so I do not have to write this code everywhere.SELECT id, action from actiontable - would return multiple recordsEXEC LogInsert SELECT id, action from actiontableCREATE PROCEDURE [dbo].LogInsert ( @Id int, @Action int = NULL)INSERT INTO LogInsert (id, action) VALUE (@Id, @Action ) |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-20 : 12:36:13
|
| then what you should be writing is a table valued UDF so that you can use it in select staements. Writing a procedure would require you to loop over table and pass values one by one whereas if its a table valued udf you can just apply it over entire table records by using CROSS APPLY. |
 |
|
|
|
|
|