How can I get a list of tables in a database without a timestamp column?
Any suggestions?
How can I get a list of tables in a database without a timestamp column?
Any suggestions?
Using INFORMATION SCHEMA views:
select * from INFORMATION_SCHEMA.TABLES T where NOT EXISTS
(
select 1
from INFORMATION_SCHEMA.COLUMNS
where TABLE_CATALOG = T.TABLE_CATALOG
and TABLE_SCHEMA = T.TABLE_SCHEMA
and TABLE_NAME = T.TABLE_NAME
and DATA_TYPE = 'timestamp' -- or the literal representing timestamp data type
)
Using SYS.TABLES/SYS.COLUMNS:
SELECT name FROM SYS.TABLES
WHERE object_id NOT IN (select object_id
FROM SYS.COLUMNS
WHERE system_type_id = 189)
You could use OBJECTPROPERTY
SELECT
name
FROM
sys.objects
WHERE
OBJECTPROPERTY(object_id, 'TableHasTimestamp') = 0 --null if not a table