ITPub博客

首页 > Linux操作系统 > Linux操作系统 > UPDATE查询结果范围内的数据

UPDATE查询结果范围内的数据

原创 Linux操作系统 作者:hky87 时间:2013-09-23 12:11:05 0 删除 编辑
语法
http://technet.microsoft.com/zh-cn/library/ms177523.aspx
[ WITH  [...n] ]
UPDATE 
    [ TOP ( expression ) [ PERCENT ] ] 
    { { table_alias |  | rowset_function_limited 
         [ WITH (  [ ...n ] ) ]
      }
      | @table_variable    
    }
    SET
        { column_name = { expression | DEFAULT | NULL }
          | { udt_column_name.{ { property_name = expression
                                | field_name = expression }
                                | method_name ( argument [ ,...n ] )
                              }
          }
          | column_name { .WRITE ( expression , @Offset , @Length ) }
          | @variable = expression
          | @variable = column = expression
          | column_name { += | -= | *= | /= | %= | &= | ^= | |= } expression
          | @variable { += | -= | *= | /= | %= | &= | ^= | |= } expression
          | @variable = column { += | -= | *= | /= | %= | &= | ^= | |= } expression
        } [ ,...n ] 

    [  ]
    [ FROM{  } [ ,...n ] ] 
    [ WHERE {  
            | { [ CURRENT OF 
                  { { [ GLOBAL ] cursor_name } 
                      | cursor_variable_name 
                  } 
                ]
              }
            } 
    ] 
    [ OPTION (  [ ,...n ] ) ]
[ ; ]

 ::=
{ 
    [ server_name . database_name . schema_name . 
    | database_name .[ schema_name ] . 
    | schema_name .
    ]
    table_or_view_name}

            
        
    

范例
with a as
((select u.empno,i.entrydate,u.pwd
  from PteeInfo i,dbo.User u,UserRole ur
   where i.empno=u.empno and u.empno=ur.empno and ur.role_name='PPP'
and ProJobID in (12,13)

))
update a
set pwd = ‘xxxx‘

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10314474/viewspace-773112/,如需转载,请注明出处,否则将追究法律责任。

上一篇: SQL Server中MD5加密
请登录后发表评论 登录
全部评论