当前位置: 移动技术网 > IT编程>数据库>MSSQL > MS SQL的CASE...WHEN...THEN...END语法

MS SQL的CASE...WHEN...THEN...END语法

2019年05月21日  | 移动技术网IT编程  | 我要评论

北京的金山上原唱,蔬菜种类,百姓网郑州

根据多个可能的答案检查一个值或变量。

举例说明:

 

select [type],case [type] 
              when 'tt' then 'type_table'
              when 'fn' then 'sql_scalar_function'
              when 'c' then 'check_constraint'
              when 'sq' then 'service_queue' 
              when 'f' then 'foreign_key_constraint' 
              when 'u' then 'user_table' 
              when 'd' then 'default_constraint' 
              when 'pk' then 'primary_key_constraint'
              when 's' then 'system_table' 
              when 'it' then 'internal_table' 
              when 'p' then 'sql_stored_procedure' 
              when 'tf' then 'sql_table_valued_function' 
              when 'tr' then 'sql_trigger' 
              end as [type description]
from (
    select distinct [type] from sys.objects
) o
    

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网