使用Ccur将Microsoft访问SQL查询转换为SQL Server

时间:2014-08-22 11:51:48

标签: sql sql-server tsql ms-access

尝试将此SQL语句从Microsoft访问转换为SQL Server。我知道SQL Server不使用Ccur而是使用CONVERT吗?

SELECT 
Ccur(Choose(IIF(IsNull(SCStatus),1
,IIF(SCStatus=0,1,2))
,IIF(IsNull(TaxTDThisEmt),0
,TaxTDThisEmt)
,IIF(IsNull(SCTaxYTD),0
,SCTaxYTD))) AS [Tax This Employment]
FROM EeBals

1 个答案:

答案 0 :(得分:1)

这样的事情会让你接近:

SELECT 
    CAST(
            (
                 CASE WHEN ISNULL(SCStatus, 0) = 0 THEN ISNULL(TaxTDThisEmt, 0)
                 ELSE ISNULL(SCTaxYTD, 0) 
                 END
            ) as money
    ) as [Tax This Employment] 
FROM Table