Isql syntax error in UNIX script

Hello Everyone,

Coming again for your help to solve the below error:

In a script, i had created a temp table (Temp_table) and loaded the data in it using bcp command (performed successfully) and I wanted to move it to the preferred table (called Main_table) for further use. hence I have added the following code:

isql -U$DBLogin -PPassed -S$DBName -e <<!
   use $schema
go
   if exists (select 1 from syscolumns where id = object_id('Main_table') and name = 'Column1')
   begin
   insert into Main_table select * from $db..Temp_table
   end
else
   begin
   create table Main_table
   (
        Column1 char (5),
        Column2 int
   )

   insert into Main_table select * from $db..Temp_table
   end
go
   DROP TABLE $db..Temp_table
go
!

But, I have got the following error message:

Msg 208, Level 16, State 1:
Main_table not found. Specify owner.objectname or use sp_help to
check whether the object exists (sp_help may produce lots of output).
Msg 208, Level 16, State 1:
Main_table not found. Specify owner.objectname or use sp_help to
check whether the object exists (sp_help may produce lots of output).

Please have a look and advise the error in my query.

Thank you

Why are you double posting in multiple forums?

This thread is closed.

Continue here: