I use the following query to collect information about table 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 null results, can I declare that the table does not exist? Or is it somehow possible that the table exists, but (perversely) has no columns?
I am already querying INFORMATION_SCHEMA.TABLES to find out if a table exists, but I would like to reduce it to one query if possible.
For future reference, I found the following questions:
Create table without columns
Can I select 0 columns in SQL Server?
sql sql-server
Greg
source share