I am importing data from another server into an archive database. I'm doing it the "easy" way by executing a dynamic sql statement as such:
select @qst = 'SELECT * INTO ' + @schema + '.' + @table + ' FROM AS400.TMS.' + @schema + '.' + @table
select @err = @@ERROR
I'm doing this in a loop to move all the tables in a particular library (schema). Here is the problem:
When the query fails it bombs out of the batch entirely, such as when the table has no columns. I'm trying to catch the error and then continue on. Any ideas on how to accomplish this?