This article will answer you the below questions,
1. Is it possible to execute a stored procedure inside a stored procedure?
2. How to insert a data into a table from stored procedure output?
-- Am trying to create temporary tables
create table venkattable(id int, name1 varchar(100))
create table venkattable1(id int, name1 varchar(100))
-- Inserting data into my table
insert into venkattable values(1,'Venkat1')
insert into venkattable values(2,'Venkat2')
insert into venkattable values(3,'Venkat3')
insert into venkattable values(4,'Venkat4')
insert into venkattable values(5,'Venkat5')
insert into venkattable values(6,'Venkat6')
select * from venkattable
--Creating first stored procedure
create procedure venkatproc1
as begin
select * from venkattable where id=2
end
exec venkatproc1
--Creating second stored procedure
create proc venkatproc2
as begin
-- Output of a stored procedure into a sql server table
insert venkattable1 exec venkatproc1
end
exec venkatproc2
-- Checking for the output
select * from venkattable1
Thanks and Regards,
Venkatesan Prabu .J
No comments:
Post a Comment