SQL查询没有输出我希望他们做的事情

时间:2018-05-08 15:13:30

标签: sql sql-server database

这是我的问题:

Select * into [HowToFix_onefile]  from  [actions_onefile]

ALTER TABLE
    HowToFix_onefile
ADD [HowToFix] AS
    CASE 
         WHEN [Error Messages] LIKE 'Different Security Type%'  AND NOT [Actions] = 'not being scanned' THEN 'Change to NFS'
         WHEN [Error Messages] LIKE 'Pruned%'  AND NOT [Actions] = 'not being scanned' THEN 'Change to NFS'
         WHEN [Error Messages] LIKE '%mismatch%' AND NOT [Actions] = 'not being scanned' THEN 'Change to NFS'
         WHEN [Error Messages] LIKE '%mismatch%' AND [protocol] LIKE 'CIFS' AND [Scanned] LIKE 'Yes' THEN 'Backend problem. Security is not visible'
         WHEN [Error Messages] LIKE 'Access%' AND NOT [Actions] = 'not being scanned' THEN 'Give permission to Varonis'
         WHEN [Error Messages] LIKE 'The inherited%' OR [Error Messages] LIKE '%path%' OR [Error Messages] LIKE 'missing inheritance%' THEN 'Ignore Error'      
         WHEN [protocol] LIKE 'NFS' AND [DirsCount] = 0 AND [Scanned] = 'in Shares table, but not SortedDirectoryTree properties' THEN 'Backend problems. Security is not visible'
         WHEN [protocol] LIKE 'CIFS' AND  [Scanned] = 'in Shares table, but not SortedDirectoryTree properties' THEN 'Backend problems. Security is not visible'
         WHEN [Protocol] LIKE 'CIFS & NIFS%' AND [Scanned] = 'in Shares table, but not SortedDirectoryTree properties' THEN 'Change to NFS'
        ELSE '' END

例如,这个输出看起来像:

  

CIFS 监控类型不匹配实际安全类型(1)需要   行动后端问题。安全性不可见。

但它看起来像:

  

CIFS监视器类型不匹配实际安全类型(1)是需要   更改为NFS

应该说'后端问题。安全性不明显。这是因为它符合标准:协议是CIFS,错误中包含“不匹配”,扫描为“是”。显示为斜体。

我尝试过切换订单,玩'%',但它仍然没有用。会不胜感激一些建议!

1 个答案:

答案 0 :(得分:3)

这是一个订购问题。这种排序应解决这个特殊问题,但可能会引入其他问题:

     WHEN [Error Messages] LIKE '%mismatch%' AND [protocol] LIKE 'CIFS' AND [Scanned] LIKE 'Yes' THEN 'Backend problem. Security is not visible'
     WHEN [Error Messages] LIKE 'Different Security Type%'  AND NOT [Actions] = 'not being scanned' THEN 'Change to NFS'
     WHEN [Error Messages] LIKE 'Pruned%'  AND NOT [Actions] = 'not being scanned' THEN 'Change to NFS'
     WHEN [Error Messages] LIKE '%mismatch%' AND NOT [Actions] = 'not being scanned' THEN 'Change to NFS'
     WHEN [Error Messages] LIKE 'Access%' AND NOT [Actions] = 'not being scanned' THEN 'Give permission to Varonis'
     WHEN [Error Messages] LIKE 'The inherited%' OR [Error Messages] LIKE '%path%' OR [Error Messages] LIKE 'missing inheritance%' THEN 'Ignore Error'      
     WHEN [protocol] LIKE 'NFS' AND [DirsCount] = 0 AND [Scanned] = 'in Shares table, but not SortedDirectoryTree properties' THEN 'Backend problems. Security is not visible'
     WHEN [protocol] LIKE 'CIFS' AND  [Scanned] = 'in Shares table, but not SortedDirectoryTree properties' THEN 'Backend problems. Security is not visible'
     WHEN [Protocol] LIKE 'CIFS & NIFS%' AND [Scanned] = 'in Shares table, but not SortedDirectoryTree properties' THEN 'Change to NFS'
    ELSE '' END
相关问题