谁能让我知道该查询来查找所有带有日期列的表。

谢谢

最佳答案

这应该可以解决问题,仅在需要时添加其他类型:

select
    so.name table_name
   ,sc.name column_name
   ,st.name data_type
from sysobjects so
inner join syscolumns sc on (so.id = sc.id)
inner join systypes st on (st.type = sc.type)
where so.type = 'U'
and st.name IN ('DATETIME', 'DATE', 'TIME', 'SMALLDATETIME')

编辑:在Sybase和任何其他T-SQL变体中也适用。

关于sql-server-2005 - 查询以查找其中带有日期列的所有表,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/358410/

10-10 23:34
查看更多