I'm using the following query to gather information about a table's columns:
SELECT COLUMN_NAME,
ORDINAL_POSITION,
DATA_TYPE,
CHARACTER_MAXIMUM_LENGTH,
Is_NULLABLE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'TableName'
ORDER BY ORDINAL_POSITION
If this query returns zero results, can I safety declare that the table doesn't exist? Or is is somehow possible that the table exists but (perversely) has no columns?
I'm already querying INFORMATION_SCHEMA.TABLES
to find out if the table exists, but I'd like to cut it down to one query if possible.
For future reference, I found these related questions:
Create a table without columns
Can I select 0 columns in SQL Server?