sql中更新数据库用到declare @a in

declare @a in

update TB_Class set @a=1,name='李小龙' where ID=1

这样就可以像更新哪个就更新哪个了

例如ibatisnet中需要更新的时候:

 <update id="Update" parameterClass="OrderStatusNeedSendToCps">

      <!--update N_OrderStatusNeedSendToCps

      set

      OrderStatus=#OrderStatus#

      ,CpsCode=#CpsCode#

      ,ContentType=#ContentType#

      ,IsSendToCps=#IsSendToCps#

      ,SendTime=getdate()

      ,ErrMessage=#ErrMessage#

      where Id=#Id#-->

      

      

      declare @a int

      update N_OrderStatusNeedSendToCps set @a=1

      <dynamic>

        <isNotNull prepend="," property="OrderStatus">

          OrderStatus=#OrderStatus#

        </isNotNull>

        <isNotNull prepend="," property="CpsCode">

          CpsCode=#CpsCode#

        </isNotNull>

        <isNotNull prepend="," property="ContentType">

          ContentType=#ContentType#

        </isNotNull>

        <isNotNull prepend="," property="IsSendToCps">

          IsSendToCps=#IsSendToCps#

        </isNotNull>

        <isNotNull prepend="," property="SendTime">

          SendTime=getdate()

        </isNotNull>

        <isNotNull prepend="," property="ErrMessage">

          ErrMessage=#ErrMessage#

        </isNotNull>

      </dynamic>

      where Id=#Id#

    </update>
View Code

 

你可能感兴趣的:(sql)