Does NULL have a data type?

后端 未结 5 1993
我在风中等你
我在风中等你 2021-01-04 21:37

I ran into code similar to this today.

SELECT AuditDomain, 
    ObjectId,
    AuditSubdomain = CONVERT(VARCHAR(50), NULL),
    SubDomainObjectId = CONVERT(IN         


        
5条回答
  •  鱼传尺愫
    2021-01-04 22:11

    Of couse NULL has data type. Try next code to confirm:

    SELECT 
      CAST(NULL AS date) AS c1,
      CAST(NULL AS time) AS c2
    INTO #x;
    EXEC tempdb..sp_columns '#x';
    

    And i think that there is bug in SQL_VARIANT implementation because it lossing information about NULL type. Too bad!

提交回复
热议问题