| Author |
Topic |
|
messi
Starting Member
47 Posts |
Posted - 2008-09-09 : 19:29:03
|
i made 2 spsp1:create proc one(@st int,@en int)Asinsert source (start,endv)values(@st,@en)i want to use @st&@en values in another spcan i do that... |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-09-09 : 19:30:38
|
| Yes. You've got them as input parameters, so your application already knows the values. Just pass the values to the other stored procedure. You should also be aware of OUTPUT parameters.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog |
 |
|
|
messi
Starting Member
47 Posts |
Posted - 2008-09-10 : 08:54:25
|
| thanks ,but how i can do this with code..(pass the values to the other stored procedure. ) |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-09-10 : 08:59:16
|
Are you calling both the sp from the same program ? You would have the value of @st and @en to pass to the 1st SP, just use it to pass to the 2nd SP.exec one @st, @enexec two @st, @en What is your issue here ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
sunil
Constraint Violating Yak Guru
282 Posts |
Posted - 2008-09-10 : 09:00:00
|
| Not sure If I understand you. You can easily pass parameters from one SP to another. See code below:create proc SP2(@st int,@en int)ASBEGIN --DO something using input parametersENDcreate proc one(@st int,@en int)AsBEGINinsert source (start,endv)values(@st,@en)exec SP2 @st,@enEND |
 |
|
|
messi
Starting Member
47 Posts |
Posted - 2008-09-10 : 09:12:23
|
| Thanks all i will try it and replay |
 |
|
|
messi
Starting Member
47 Posts |
Posted - 2008-09-10 : 10:18:11
|
i tried but it did nothingso i put image to give you more help |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-09-10 : 10:35:51
|
how are these 2 SP invoke ?adds will exec sourceins ?or sourceins will exec adds ?or both are exec from another SP or your application ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
messi
Starting Member
47 Posts |
Posted - 2008-09-10 : 10:46:42
|
| No ,sourceins will exec from my applicationadds will exec from a trigger look i will tell you my idea :i will enter 2 numbers in my application this 2 num will saved by (sp sourceins) in source tablethen i made trigger: when i insert 2 num in source table the trigger will exec (adds SP)soi need to store this 2 num values in (adds SP) in here(look image) |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-09-10 : 11:05:35
|
it is in the inserted table KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
messi
Starting Member
47 Posts |
Posted - 2008-09-10 : 17:11:39
|
| Sorry i don't understand .. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-09-11 : 01:07:30
|
your stored procedure adds is basically execute in the trigger. When trigger executes, there are 2 tables available which is the inserted and deleted table.see http://msdn.microsoft.com/en-us/library/aa258254.aspxquote: A few special tables are used in CREATE TRIGGER statements: * deleted and inserted are logical (conceptual) tables. They are structurally similar to the table on which the trigger is defined, that is, the table on which the user action is attempted, and hold the old values or new values of the rows that may be changed by the user action
the inserted table will contains rows (note : maybe more than 1 rows) of the inserted value. The value you want will be available in the inserted table KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|