SQL SELECT with a missing column

Microsoft SQL Server

Consider the following simple SQL SELECT statement:

SELECT LastName,MiddleName,FirstName FROM Persons

For the sake of this discussion, let's assume the table name (in this
case "Persons") comes from an outside source. Sometimes that database
has the "MiddleName" property / column, other times it does not.

Under Windows SQL, I'm finding that the query fill fail returing that
it's an invalid query if the requested property / column is not there.

My question is this. I want to make a SQL statement that says return
these columns but skip any columns if they're not present. Is there a
way to do this? Thanks!
yes, but it is ugly. You would need to dynamically create the select
statement based on column information for the table contained in system
metadata (INFORMATION_SCHEMA.. or sysobjects/syscolumns).