Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在编写一个需要执行SWITCH字符串变量并根据值执行不同操作的存储过程,伪代码可能是:
SWITCH
CASE @my_string WHEN 'value' UPDATE table 1 WHEN 'Other_value' UPDATE table 2
我找不到任何以这种方式完成的开关示例,是否有可能或者我IF/ELSE每次都需要使用?
IF/ELSE
谢谢
使用IF将是典型的方式:
IF
IF @my_string = 'value' BEGIN UPDATE SomeTable WHERE somecondition END IF @my_string = 'Other_value' BEGIN UPDATE SomeOtherTable WHERE somecondition END