The version of
[Parts].[sp_get_parts]
that you have shared does not contain any references to column
onlineid
so executing it cannot possibly produce an error "invalid column name onlineid". You must be getting that error in some code that you have not shared with us.
The only columns in the table
Extractreports.dbo.PartGeneration
are
partid
and
companyname
- it doesn't matter if you have added other columns before calling the SP because you literally destroy the table before doing anything else in that SP - so whatever you did before calling the SP is not available to you afterwards.
If you do something like ...
Alter Extractreports.dbo.PartGeneration to add column onlineid
execute [Parts].[sp_get_parts]
select * from [Parts].[sp_get_parts]
You will see there are only those two columns.
You have several options, for example:
1. Do not drop the table, just truncate it (as advised in Solution 1) and change the way you insert data e.g.
INSERT into Extractreports.dbo.PartGeneration (partid, companyname) select partid,companyname from dbo.parts
2. Or, Drop the table but include onlineid in the select that recreates it e.g.
select partid,companyname,0 as onlineid into Extractreports.dbo.PartGeneration from dbo.parts