[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 521
  • Last Modified:

Get specific column types for a table

I'm on a job where they have massive tables (80+ columns)

Is there a select I can run on a table where I get back ONLY the columns that are datetime types?
1 Solution
Habib PourfardCommented:
SELECT c.[name] AS [Column Name]
FROM syscolumns c
INNER JOIN sysobjects o ON c.id = o.id 
INNER JOIN sys.types t ON c.xtype = t.system_type_id
WHERE o.type = 'u' AND t.NAME = 'datetime' AND  o.[Name] = 'YourTable'

Open in new window

lrbristerAuthor Commented:
Remind me to buy you a sody-pop sometime!

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now