I have some complex stored procedures pulling data from other databases using linked servers. This data is put into temp tables which are joined in a select query for output. The procedures work fine but in visual studio if I try to add the stored procedure to a dataset using the designer I get the error invalid object name #tmp or whatever the first temp table is called. It is unable to retrieve the database schema. It's the same for using and sqldatasource in ASP.NET.
The procedure is still usable but I have to manually add all the columns it should output to the datatable. This is going to be a pain to do manually and I assume it is to do with the way visual studio gathers the output fields from the stored procedure, it doesn't seem to run it in the normal way. Is there a way to correct this as I have quite a lot of these to do and don't want to have to add all the columns manually, which is time consuming and error prone.