The commercial product I am working with uses a slightly more complicated query than the query below. The query and in particular the list of columns is created in the software.
The query is presented to the server via software and an ODBC link to the database.
If the query runs okay, the columns exist.
If the query fails, then further queries are executed and the missing columns created etc, so that the software always has the tables and columns it needs to run correctly.
The solution differs from many solutions above, which do handle SQL Server tables, but would be too restrictive for our product. Things like INFORMATION_SCHEMA.COLUMNS, sys.columns and object_id() may well prevent our software working on other databases like MySQL, etc.
On the other hand, our queries could crash an SQL script interpreter, so are unlikely to be suitable for everyone. If your queries are run by your own software and an ODBC connection to the SQL Server, and you want them to run with databases other than SQL Server too, then this approach might be worth consideration.