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 2005 Forums
 Transact-SQL (2005)
 SP: use output as input

Author  Topic 

hanavan
Starting Member

25 Posts

Posted - 2008-09-15 : 17:01:36
I have a stored procedure with 3 variables:
@customerid
@from
@to

I can run this by doing:
exec SP
@customerid ='|customer|,130',
@from = 'info@test.com',
@to = 'test@tes.com';

This is working great, but I want to use data from a table (dbo.Parameter01) in which I have customerid, from and to.

Table structure:
customerid - from - to
130 - info@test.com - test@test.com
350 - A1@a2.com - test@test.com

What I want is to use the output of the table, in the exec statement. But I can't see how I can do it.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-09-15 : 18:11:17
SELECT @from = SomeColumn1, @to = SomeColumn2
FROM Table1
WHERE ...

EXEC yourSP @input1 = @from, @input2 = @to, ...

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-15 : 23:58:18
and you would obviously have to loop if you want procedure to be executed for each row values of table.
Go to Top of Page

hanavan
Starting Member

25 Posts

Posted - 2008-09-16 : 16:43:03
Thank you,
It worked.

Go to Top of Page
   

- Advertisement -