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

前端 未结 13 1462
耶瑟儿~
耶瑟儿~ 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:31

    You can also use...

    SQL_VARIANT_PROPERTY()
    

    ...in cases where you don't have direct access to the metadata (e.g. a linked server query perhaps?).

    • SQL_VARIANT_PROPERTY (Transact-SQL)

    In SQL Server 2005 and beyond you are better off using the catalog views (sys.columns) as opposed to INFORMATION_SCHEMA. Unless portability to other platforms is important. Just keep in mind that the INFORMATION_SCHEMA views won't change and so they will progressively be lacking information on new features etc. in successive versions of SQL Server.

提交回复
热议问题