DevPinoy.org
A Filipino Developers Community
   
HOWTO: INSERT RECORD SET FROM STORED PROC (SQL SERVER)

Suppose that you need to populate record set from a stored procedure. This is how it's being done:

CREATE PROC NameList

AS

SET NOCOUNT ON

SELECT Emp_FNAME, Emp_LNAME

From Emp_Table

SELECT FName, LName

From Table_of_Names

RETURN

 

When you execute this Stored Proc, it gives you something like this:

--First Set 

Emp_FNAME   Emp_LNAME

----------             -------------

John                  Doe

Jane                 Ramos

 --Second Set

FName             LName

----------               -----------

Jack                 Daniels

Juan                 Cruz

 

Suppose you have this Table structure [Target]:

CREATE TABLE dbo.MyNameTable

(First_Name VARCHAR (55),

Last_Name VARCHAR (55) )

 

You can insert the record set from the stored proc to the target table dbo.MyNameTable like this:

INSERT dbo.MyNameTable (First_Name, LastName)

EXEC NameList

 

Hope this helps.


Posted 01-11-2008 1:40 PM by marl

Comments

Meaning Of Names » HOWTO: INSERT RECORD SET FROM STORED PROC (SQL SERVER) wrote Meaning Of Names » HOWTO: INSERT RECORD SET FROM STORED PROC (SQL SERVER)
on 01-11-2008 4:56 PM

Pingback from  Meaning Of Names » HOWTO: INSERT RECORD SET FROM STORED PROC (SQL SERVER)

Copyright DevPinoy 2005-2008