I meant "there is an empty table with no cols and rows in returned dataset"
ahh... so you want the missing table to have a stub in your DataSet
? Seems pretty... oddd - but I guess you could do something like:
if object_id('table2') is not null -- yeuch yeuch yeuch (see below)
begin
select * from table2
end
else
begin
select 1 where 1 = 0
end
Again, I stress that I find this desire... unusual; but:
- if we
select
even if there isn't data, we just get an empty table, which is fine
- if the table doesn't exist, we just get a 1-column, 0-row stub
There are better ways of checking for existance of an object - for example, checking the info-schema tables; but I'm still not convinced that it is (in the general case) sensible to be overly concerned about existence / non-existence of tables, unless you're:
- writing tooling, such as a query analyzer or ORM tool
- writing a data impoty utility that can't trust ad-hoc data