案例陈述未加入表

时间:2016-10-06 09:28:35

标签: sql sql-server

这是我的查询

SELECT migrationref,
       dbo.Firstnamecheck(firstname, contacttype)         AS FirstNameCheck,
       dbo.Lastnamecheck(lastname, contacttype)           AS LastNameCheck,
       dbo.Corporatenamecheck(corporatename, contacttype) AS CorporateNameCheck,
       dbo.Advisercheck(adviser, advisermigrationref)     AS AdviserCheck
INTO   ##clientvalidcheck
FROM   clientimports

DELETE FROM ##clientvalidcheck
WHERE  ( firstnamecheck IS NULL
         AND lastnamecheck IS NULL
         AND corporatenamecheck IS NULL
         AND advisercheck IS NULL );

SELECT *
FROM   ##clientvalidcheck

SELECT CASE firstnamecheck
         WHEN 'ERROR' THEN 'FirstName caused an Error.'
       END "FNValidationError"
FROM   ##clientvalidcheck; 

根据我的理解,当您使用案例陈述时,它会在表的末尾添加一列以显示语句的结果,但对我而言,它会生成一个不属于表的新列。无论如何加入这两个?

2 个答案:

答案 0 :(得分:1)

像它一样修改

Select t1.*, CASE t1.FirstNameCheck WHEN 'ERROR' THEN 'FirstName caused an Error.' END "FNValidationError"
FROM ##ClientValidCheck  t1;

答案 1 :(得分:0)

使用:

#if defined(_WIN64)
   #if defined(_AMD64_)
      #define PROBE_ALIGNMENT( _s ) TYPE_ALIGNMENT( DWORD )
   #elif defined(_IA64_)
      #define PROBE_ALIGNMENT( _s ) (TYPE_ALIGNMENT( _s ) > TYPE_ALIGNMENT( DWORD) ? \
                          TYPE_ALIGNMENT( _s ) : TYPE_ALIGNMENT( DWORD ))
   #else
      #error "No Target Architecture"
   #endif

   #define PROBE_ALIGNMENT32( _s ) TYPE_ALIGNMENT( DWORD )

#else
   #define PROBE_ALIGNMENT( _s ) TYPE_ALIGNMENT( DWORD )
#endif