Datatype stored

  • Can anybody let me know if is there any way to pull which table has got particualr datatype in a database?

    For example,

    We have a database 'advance', this database has got 40 tables. The question is out of 40 tables which tables has got 'image' as datatype? with lesser effort?

    Please advise

    Thanks.

  • Sure

    DECLARE @DataType SYSNAME;

    SET @DataType = 'image';

    SELECT OBJECT_NAME(object_id) AS TableName ,

    c.name AS ColumnName ,

    t.name AS Type

    FROM sys.columns AS c

    INNER JOIN sys.types AS t ON c.system_type_id = t.system_type_id

    WHERE t.name = @DataType;

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Thanks A lot.

  • You can also take a look at the free Red Gate utility SQL Search[/url]. It'll hit all the databases at the same time.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply