Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 更新SQL Server中的多行_Sql Server - Fatal编程技术网

Sql server 更新SQL Server中的多行

Sql server 更新SQL Server中的多行,sql-server,Sql Server,我的桌子看起来像这样: c1 c2 c3 a 1 2000 a 2 2001 a 3 3000 a 4 3001 a 5 3002 步骤1:删除c3=20002001的行 Delete table where c3 like '2___' 步骤2:将3000更改为2000,3001更改为2001,3002更改为2002,依此类推 我被困在这里了。如果有任何建议或例子,我将不胜感激 删除(2000、2001)中c3所在的表名 删除c3类似“2%”的表名。 更新表名集c3=

我的桌子看起来像这样:

c1 c2 c3
a   1 2000
a   2 2001
a   3 3000
a   4 3001
a   5 3002
步骤1:删除c3=20002001的行

Delete table where c3 like '2___' 
步骤2:将3000更改为2000,3001更改为2001,3002更改为2002,依此类推

我被困在这里了。如果有任何建议或例子,我将不胜感激

  • 删除(2000、2001)中c3所在的表名

    删除c3类似“2%”的表名。

  • 更新表名集c3=c3-1000

  • 删除(2000、2001)中c3所在的表名

    删除c3类似“2%”的表名。

  • 更新表名集c3=c3-1000

  • 尝试:

    删除c3所在的表格(20002001)
    更新您的表
    设置C3=C3-1000
    其中c3>=3000和c3尝试:

    删除c3所在的表格(20002001)
    更新您的表
    设置C3=C3-1000
    
    其中c3>=3000和c3假设c3列是字符串(您不说):


    假设C3列为整数:

    delete MyTable where c3 between 2000 and 2999
    update MyTable set c3 = c3 - 1000 where c3 between 3000 and 3999
    

    假设C3列是字符串(您不会说):


    假设C3列为整数:

    delete MyTable where c3 between 2000 and 2999
    update MyTable set c3 = c3 - 1000 where c3 between 3000 and 3999
    
    delete MyTable where c3 between 2000 and 2999
    update MyTable set c3 = c3 - 1000 where c3 between 3000 and 3999