Saturday, February 25, 2012

call a stored proc from a stored proc

I need to call a stored select proc frmo an update stored proc. How do I do
it.
here is the proc that does the call
INSERT INTO tblFileRecords_Stage2 ( FirstName, LastName......)
SELECT CALLEDStoreproc.FirstName ,
CALLEDStoreproc.s.LastName, ....
FROM CALLEDStoreproc
The proc CALLEDStoreproc looks somehing like this
SELECT Min(SID, FirstName, LastName....
FROM tblFileRecords_tmp......The construct you'd use here would be INSERT ... EXEC() like:
INSERT tblFileRecords_Stage2 ( FirstName, LastName...... )
EXEC CALLEDStoreproc ;
Anith|||"Rick Morayniss" <RickMorayniss@.discussions.microsoft.com> wrote in message
news:B74B0E28-5C9E-4E0C-ADAD-AC228BF17BDE@.microsoft.com...
>I need to call a stored select proc frmo an update stored proc. How do I do
>it.
> here is the proc that does the call
> INSERT INTO tblFileRecords_Stage2 ( FirstName, LastName......)
> SELECT CALLEDStoreproc.FirstName ,
> CALLEDStoreproc.s.LastName, ....
> FROM CALLEDStoreproc
> The proc CALLEDStoreproc looks somehing like this
> SELECT Min(SID, FirstName, LastName....
> FROM tblFileRecords_tmp......
>
INSERT INTO tblFileRecords_Stage2 (sid, FirstName, LastName)
EXEC dbo.usp_procedure ;
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--

No comments:

Post a Comment