如何在SQL Server中使用多个更新查询

时间:2018-10-13 03:37:03

标签: sql-server

我要更新Data_type,其中Data_Type包含Null或除D之外的字符串 如果有任何字符串,我该如何编码

Update Table_Name
Set Data_Type='D'
Where Data_type is Null 
   or Data_type = ' ' or like Data_type %[A-C]% or Data_Type %[e-z]%
Go
--

1 个答案:

答案 0 :(得分:1)

您的语法错误。应该是

Update Table_Name
Set    Data_Type = 'D'
Where  Data_Type <> 'D'
and    src_hm    <> 1
and   (
       Data_type is Null 
or     Data_type = ' ' 
or     Data_type like %[A-C]% 
or     Data_Type like %[e-z]%
      )