Get specific column types for a table

Posted on 2012-08-22
Last Modified: 2012-08-22
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?
Question by:lrbrister
    LVL 12

    Accepted Solution

    SELECT c.[name] AS [Column Name]
    FROM syscolumns c
    INNER JOIN sysobjects o ON = 
    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


    Author Closing Comment

    Remind me to buy you a sody-pop sometime!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
    Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now