| Author |
Topic |
|
BuddyRam
Starting Member
17 Posts |
Posted - 2007-04-12 : 08:04:52
|
| I am very new sql server but i need to write a SP which will contains one select stamet and one insert staement.I need to get value from select statment that i need to insert into other table?here is my SP:create PROCEDURE [dbo].[sp_geteventid](@register_id int) ASdeclare @eventid int select event_id into @eventid from tbl_register where register_id =@register_id insert into tbl_dummy values(@eventid) Ho can i insert my event_id into tbl_dummy which i got from select statementadvanced thanksRam..CheersRam |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-12 : 08:09:36
|
use the INSERT INTO .. SELECT syntaxinsert into tbl_dummyselect event_idfrom tbl_registerwhere register_id = @register_id KH |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-12 : 08:10:24
|
| create PROCEDURE [dbo].[sp_geteventid](@register_id int) ASdeclare @eventid int select @eventid = event_id from tbl_register where register_id =@register_id insert into tbl_dummy values(@eventid) orcreate PROCEDURE [dbo].[sp_geteventid]( @register_id int)ASinsert tbl_dummySELECT event_idfrom tbl_registerwhere register_id = @register_id Peter LarssonHelsingborg, Sweden |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-12 : 08:11:11
|
you better define the column name in the insert into column listinsert into tbl_dummy(column_name)select event_idfrom tbl_registerwhere register_id = @register_id KH |
 |
|
|
BuddyRam
Starting Member
17 Posts |
Posted - 2007-04-12 : 08:14:14
|
| Thank you very much i get ride off that..CheersRam |
 |
|
|
Jeff Moden
Aged Yak Warrior
652 Posts |
Posted - 2007-04-12 : 23:11:04
|
| Sounds a lot like an interview question especially since its "urgent".--Jeff Moden |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-04-13 : 01:39:49
|
how do you have time during an interview to post questions here?or are there interviews with "take-home" questions? www.elsasoft.org |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-13 : 02:17:30
|
| My colleague once caught a candidate of mine, during an interview, asking a friend over the phone what the answer is.The candidate said he needed to go to the men's room and my colleague was there too...Peter LarssonHelsingborg, Sweden |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
cmdr_skywalker
Posting Yak Master
159 Posts |
Posted - 2007-04-13 : 13:38:55
|
| Very Urgent?! It just amaze me of the audacity of such pachydermatous hominid to delude the magnanimity of chosen few with a fraud cry or poor choice of words. I wonder if the SP you gave came from your own labor or was the code from someone else too? Most people who cherish the labor of ones work will take some effort to exhaust all available resources on-hand (a.k.a. BOL, google) before asking someone's to give up their precious time to provide benevolent assistance. Check out R.E.S.P.E.C.T., you'll find it close with the phrase "OTHERS AS YOU RESPECT YOURSELF" :). May the Almighty God bless us all!www.empoweredinformationsystems.com |
 |
|
|
|