i) result of print statement is
select * from DB2..viewname
ii) running manually works ok.
iii) The issue is when we run the proc from DB1 which selects from a view in DB2 and there is an object with the same name in DB1.
iv) The error message is (when running from DB1)
The request for view 'DB2.dbo.view_name' failed because
'DB2.dbo.view_name' is a procedure object.
Incidently, here's the order of what we did - which seems to be important
1) Create view DB2..view_name
2) Create table DB1..ValidateData
Everything runs ok with current db DB1
3) Drop view DB2..view_name
4) Create view DB2..view_name (view is given same object_id as an object in DB1)
Get error message.
I suspect the set statement_cache off would have worked. It feels like Sybase is running
checks against compiled information and dropping the view causes a full recompile.