473,396 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

INSERT SELECT with Stored Procedures?


A cool feature of SQL is that I can use a SELECT statement and pass
values into an INSERT -- great for moving a few records between tables.

Question, is there a way to use a SELECT to pass values into a stored
procedure?
--
The Texeme Construct
http://you-read-it-here-first.com
Nov 17 '06 #1
3 1063
Hi John,

AFAIK, no (unfortunately).

--
Dave Sexton

"John Bailo" <ja*****@texeme.comwrote in message
news:ic******************************@speakeasy.ne t...
>
A cool feature of SQL is that I can use a SELECT statement and pass values
into an INSERT -- great for moving a few records between tables.

Question, is there a way to use a SELECT to pass values into a stored
procedure?
--
The Texeme Construct
http://you-read-it-here-first.com


Nov 17 '06 #2
ye,of cource you can do that

sample SP shows as below:

CREATE PROCEDURE ShowAFile
@FileNo nvarchar(50)
as
select c.FileNO,
c.Name,
c.Sex ,
c.Birthday,
e.RaceName,
c.Political,
c.PriQualify,
c.PriGradSchool,
c.PriGradDate,
c.Qualify,
c.GradSchool,
c.GradDate,
b.DutyName ,
f.TitleName,
d.JobName,
a.DeptName,
c.WorkDate,
c.EnterDate,
c.OrgDate间,
c.Origin,
c.Resume
from Departments a,Duties b,Files c,Jobs d,Races e,Titles f
where a.DeptID=c.DeptID and b.DutyID=c.DutyID and d.JobID=c.JobID and
e.RaceID=c.RaceID
and f.TitleID=c.TitleID
and c.FileNo=@FileNo
GO

--------------------------------------------
Not a good SP but can tell that you can pass values into a SELECT SP

John Bailo 寫道:
A cool feature of SQL is that I can use a SELECT statement and pass
values into an INSERT -- great for moving a few records between tables.

Question, is there a way to use a SELECT to pass values into a stored
procedure?
--
The Texeme Construct
http://you-read-it-here-first.com
Nov 19 '06 #3
Garfilone wrote:
ye,of cource you can do that

sample SP shows as below:

<snip>
--------------------------------------------
Not a good SP but can tell that you can pass values into a SELECT SP
That's not what he asked. He wants the result set from the Select
statement to be passed INTO the stored procedure. In SQL you can do
this:

INSERT Into tablename SELECT * From whatever

This uses the results of the select as the field values for the insert.
I believe the OP wants to do a similar action using a stored procedure
instead of an insert statement:

Something like this (pseudocode to illustrate point):

EXEC spStoredProcName SELECT * From Whatever

Which is not possible AFAIK.

Chris

Nov 21 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: HD | last post by:
Is there a way to let an account have execute permission on a stored procedure but not let that stored procedure run insert , delete, or update records. Basically only let them run or create stored...
7
by: Bercin Ates via SQLMonster.com | last post by:
I?m getting an error when I execute a stored procedure which is try to insert a row to a table. The error is: Server: Msg 1934, Level 16, State 1, Procedure SRV_SP_IS_EMRI_SATIRI_EKLE, Line 32...
18
by: Robin Lawrie | last post by:
Hi again, another problem! I've moved from an Access database to SQL server and am now having trouble inserting dates and times into seperate fields. I'm using ASP and the code below to get the...
2
by: Eli | last post by:
Hi all We currently have a strange problem with calling a Stored Procedure (SQL Database) in our C# Project. The only error I get is "System error" which says a lot :) Background: We have...
1
by: Max | last post by:
I'm looking for best methods in terms of performance and simplicity to do an INSERT and UPDATE. Using Microsoft's Application Blocks and SQL Server stored procedures, this is simple: Insert:...
6
by: Lelle | last post by:
Hello ! how can i insert text containg code examples from a textbox into a database using SQL insert statment. i have no problem to just add text that dont contains code and script examples...
3
by: taru | last post by:
Env: DB2 UDB 8.1 on AIX We are executing a db2 sql stored procedure which is invoked from a java client. The stored procedure contains few select, insert and update statements. Using the DB2...
1
by: satish | last post by:
hi, i had a small doubt , i have a table xxx with two columns (a int,b int ) and i have inserted 5 rows my query is to add the two colums using a stored procedure and the result has to be...
1
by: RB | last post by:
Hi All, I'm trying to use more data-adapters/data-sets in a project, because they are so awesome! Anyhoo, I want to use them with Stored Procedures, rather than raw SQL text. The hard part of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.