Is it possible in SQL Server to check whether table exists in this way? If it doesn't exists, it will run catch
declare @SQL varchar(4444)
select @SQL = '
begin try
select * from ServerName.DBName.dbo.TableNAme
end try
begin catch
select 1
end catch'
exec (@SQL)
I don't want to use solution described here , because I want to use exact same structure of table as above.
Reason: I will run several dynamic queries in loop, and above ServerName, DbName ,TableName gonna be passed as a parameter.