hi,
in my project i need one procedure i.e., first i select one row and that row is inserted into that table, how to write single stored procedure todo this.
ex: select eno,ename,sal from emp
insert into emp (eno,ename,sal) values (here we insert above selected emp values)
please give example code.
Thanks.
Select and insert stored procedure in sqlserver
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

PJ MartinsRank #2,548 · 548 reputationPosted May 27, 2010, 6:29 AM EDT
insert into emp (eno, ename, sal)
select eno, ename, sal from emp
instead of using values, simply place the select statement after the insert statement
CrishRank #1,487 · 1.1K reputationPosted May 27, 2010, 10:03 AM EDT
try below query
insert into emp (eno,ename,sal) values (select eno,ename,sal from emp)
thanks
Venkatesan JayakanthamRank #256 · 9.8K reputationPosted Jun 7, 2010, 9:59 PM EDT
create table sample_table (id int, dat datetime)
insert into sample_table values(1,getdate())
create table sample_table1 (id int, dat datetime)
Your query,
insert into sample_table1
select * from sample_table
Cheers,
Venkatesan Prabu .J