Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

getting table name while inserting/update data in a table

$
0
0

Hi ,

I want to know if a table name can be inserted into output clause dynamically without passing table name as hardcoded value in an insert statement .

say I am firing the insert statement for table itest

insert into itest (j)
output inserted.i, inserted.j,'itest' as tablename into #new
select o.object_id from sys.objects as o

so here instead of hardcoding mytable name i want a system variable / somefunction .

please help ..

thanks in advance .


Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>