在switch语句SQL中包装If语句

时间:2018-12-21 12:37:44

标签: sql-server visual-studio reporting-services

我正在尝试将if语句包装在switch语句中。有人可以告诉我如何吗?这是在Visual Studio 2012中。

kubectrl create secret docker-registry <SECRET_NAME> --docker-server <REGISTRY_NAME>.azurecr.io --docker-email <YOUR_MAIL> --docker-username=<SERVICE_PRINCIPAL_ID> --docker-password <YOUR_PASSWORD>

这是我要包括在其中的if语句:

   <ReportName>



                            =Switch(
    Fields!ERROR_CATEGORY.Value= "Tin + Tax Country", "Tin and Tax Country 
    Detail",
    Fields!ERROR_CATEGORY.Value= "Passport No + Issuing Country", "Passport 
    Issuing Country Detail",
    Fields!ERROR_CATEGORY.Value= "Lei", "Lei Detail",
    Fields!ERROR_CATEGORY.Value= "Legal Name Country Incorporation", "Legal 
    Name 
   Country Inc Detail",
   Fields!ERROR_CATEGORY.Value= "Legal Name Country Jurisdiction", "Legal 
   Name 
   Country Jur Detail",
   Fields!ERROR_CATEGORY.Value= "First Name, Surname + Dob", "First Name 
   Surname Dob Detail",
   Fields!ERROR_CATEGORY.Value= "Full Name + Dob", "Full Name Dob Detail",
   Fields!ERROR_CATEGORY.Value= "Company Reg No + Country Inc"
, "Company Reg Country Inc Detail")</ReportName>

1 个答案:

答案 0 :(得分:1)

IIF()函数返回单个值,因此,您可以随时将其合并到switch函数,或任何其他代码中的方式期望值的地方。

因此,举一个简短的例子,您可以像这样使用switch

switch(
A=1,"1",
A=2,"2"
)

并添加一个iif,如下所示:

switch(
A=1,"1",
A=2,iif(B=1,"2","two")
)