Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 query help

Author  Topic 

nextaxtion
Yak Posting Veteran

54 Posts

Posted - 2013-10-14 : 01:28:30
i had a query and i need to insert record in table and also want to select output of query.

actually i need to insert and show data in same query kinldy help


;with cte as (
select id , status
from tbl_main
where id = 15555
)
insert into testinsert (id , status)
select * from cte

prithvi nath pandey

VeeranjaneyuluAnnapureddy
Posting Yak Master

169 Posts

Posted - 2013-10-14 : 01:36:57
;with cte as (
Select Id,Status
From tbl_main
where Id = 15555
)
insert testinsert
select * from cte

veeranjaneyulu
Go to Top of Page

nextaxtion
Yak Posting Veteran

54 Posts

Posted - 2013-10-14 : 01:49:25
VeeranjaneyuluAnnapureddy ,

i had also write this query but this only inserts record in table i need to also show records.


prithvi nath pandey
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-10-14 : 01:55:38
[code]
insert into testinsert (id , status)
output inserted.id,inserted.status
select id , status
from tbl_main
where id = 15555
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -