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 |
Kickaboo
Starting Member
10 Posts |
Posted - 2008-03-28 : 13:07:45
|
Hi,I am trying to write a stored procedure, which does a couple of things.First thing is it looks up a persons Location based on an ID number, which is passed from an external Script. This will return four Values from a table.I want to insert those four values into another table, along with another ID passed to the procedure from the same script.My question is, what do I do to the script below to get the four values out of the first look up, into the insert?The Field names returned from the SELECT are, AREA1, AREA2, AREA3, AREA4ThanksDavidCREATE PROCEDURE UserAssign_Location @UserID Int, @AreaID IntASBEGIN SET NOCOUNT ON; SELECT * From Locations Where EntryID = @AreaID INSERT INTO Members_Locations (UserID, Location1, Location2, Location3, Location4, Active) VALUES (@UserID, 'AREA1', 'AREA2', 'AREA3', 'AREA4', 1)ENDGO |
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2008-03-29 : 07:32:37
|
CREATE PROCEDURE UserAssign_Location @UserID Int, @AreaID IntASBEGINSET NOCOUNT ON;INSERT INTO Members_Locations (UserID, Location1, Location2, Location3, Location4, Active)SELECT @userID as userID,AREA1,AREA2,AREA3,AREA4,1 From Locations Where EntryID = @AreaIDENDGOJack Vamvas--------------------Search IT jobs from multiple sources- http://www.ITjobfeed.com |
 |
|
|
|
|
|
|