Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/69.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
C# 如何在C中使用SQL Server 2012向用户返回事务状态#_C#_Sql_Sql Server_Transactions - Fatal编程技术网

C# 如何在C中使用SQL Server 2012向用户返回事务状态#

C# 如何在C中使用SQL Server 2012向用户返回事务状态#,c#,sql,sql-server,transactions,C#,Sql,Sql Server,Transactions,我正在使用存储过程进行数据迁移,我想给出迁移过程的用户状态。例如,如果备份已完成,则发出状态为backup completed的信号,以此类推 下面是示例存储过程 CREATE PROCEDURE sp_Migration @id int, @camid int, @output nvarchar(max) output AS BEGIN begin try Begin tran /* 1: code for backup */

我正在使用存储过程进行数据迁移,我想给出迁移过程的用户状态。例如,如果备份已完成,则发出状态为
backup completed
的信号,以此类推

下面是示例存储过程

CREATE PROCEDURE sp_Migration
    @id int,
    @camid int,
    @output nvarchar(max) output
AS
BEGIN
    begin try
    Begin tran
        /* 1: code for backup */
        exec SP_CollegeBackup

        /* 2: code migration */
        exec Sp_studentmigrtion

        /* 3: migration finished */
        commit;
    end
    begin catch
         rollback ;
    end
END
GO

我想在每一步都给用户一个状态更新,在表中写入状态并让UI从该表中读取。如果您在事务中,我想您将无法跟踪每一步的更改。注意:您不应该在存储过程中使用
sp
前缀。微软已经这样做了,而且你确实有可能在将来的某个时候发生名称冲突。最好只是简单地避免使用
sp.
并使用其他东西作为前缀,或者根本不使用前缀!