I am using the sp_Foreachtable method to grab records from a group of tables and insert them into an existing table in same db. What i would like to do is add the table name of the record in which it was found. i can add the tablename field to the exisitn table sprintdb.dbo.EbtSprintLookup to accomodate the added tablename value.
This is what i have now:
declare @mycommand varchar(128)
declare @mywhereand varchar(128)
declare @RETURN_VALUE varchar(255)
set @mycommand = 'select * from ? where Field9 = ''9995554323'' and Field1 = ''030'''
set @mywhereand = 'and o.name like ''EbtSprint2%'''
insert INTO sprintdb.dbo.EbtSprintLookup
@command1 = @mycommand,
@whereand = @mywhereand
order by abs(field3)
truncate table sprintdb.dbo.EbtSprintLookup