How do I return the SQL data types from my query?

前端 未结 13 1463
耶瑟儿~
耶瑟儿~ 2021-01-29 23:58

I\'ve a SQL query that queries an enormous (as in, hundreds of views/tables with hard-to-read names like CMM-CPP-FAP-ADD) database that I don\'t need nor want to understand. Th

13条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-30 00:49

    This will give you everything column property related.

    SELECT * INTO TMP1
    FROM ( SELECT TOP 1 /* rest of your query expression here */ );
    
    SELECT o.name AS obj_name, TYPE_NAME(c.user_type_id) AS type_name, c.*  
    FROM sys.objects AS o   
    JOIN sys.columns AS c  ON o.object_id = c.object_id  
    WHERE o.name = 'TMP1';
    
    DROP TABLE TMP1;
    

提交回复
热议问题