【问题标题】:i want to move one table row to another and delete that row from old table我想将一个表行移动到另一个表行并从旧表中删除该行
【发布时间】:2014-01-16 09:16:13
【问题描述】:
insert into dbo.OffEmployeeRecord 
select * from dbo.EmployeeRecord where Code=1 

此代码将数据从 table_1 复制到 table_2 但我想在单个查询中移动它(从第一个表复制后删除)

【问题讨论】:

    标签: asp.net c#-4.0 sql-server-2008-r2


    【解决方案1】:

    您可以编写存储过程来执行此类操作

    createProc [dbo].[ProcRemoveEmoRecord]
    (
    @CodId varchar(50)
    )
    As 
    begin
    
    insert into dbo.OffEmployeeRecord 
    select * from dbo.EmployeeRecord where Code=@CodId
    
    delete from dbo.EmployeeRecord where Code=@CodId
    
    end
    

    创建上述sp后,执行上述过程即可执行所需的动作

    【讨论】:

    • 我认为你需要在这个过程中实现事务
    猜你喜欢
    • 1970-01-01
    • 2013-11-18
    • 2016-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多