in Search

αρχάριος

greek, noun, pron. "archarios" - beginner, learner, neophyte, novice

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.

Only published comments... Jan 11 2008, 01:40 PM by marl

Comments

 

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

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

January 11, 2008 4:56 PM

Leave a Comment

(required) 
(optional)
(required) 

Enter the numbers above:
Submit