sql >> Database teknologi >  >> RDS >> Sqlserver

Returner antallet af rækker, der er påvirket af UPDATE-sætninger

CREATE PROCEDURE UpdateTables
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    DECLARE @RowCount1 INTEGER
    DECLARE @RowCount2 INTEGER
    DECLARE @RowCount3 INTEGER
    DECLARE @RowCount4 INTEGER

    UPDATE Table1 Set Column = 0 WHERE Column IS NULL
    SELECT @RowCount1 = @@ROWCOUNT
    UPDATE Table2 Set Column = 0 WHERE Column IS NULL
    SELECT @RowCount2 = @@ROWCOUNT
    UPDATE Table3 Set Column = 0 WHERE Column IS NULL
    SELECT @RowCount3 = @@ROWCOUNT
    UPDATE Table4 Set Column = 0 WHERE Column IS NULL
    SELECT @RowCount4 = @@ROWCOUNT

    SELECT @RowCount1 AS Table1, @RowCount2 AS Table2, @RowCount3 AS Table3, @RowCount4 AS Table4
END


  1. Hvordan taler Access med ODBC-datakilder? Del 4

  2. Opstilling og identifikation af rækkemål i eksekveringsplaner

  3. Udforskning af lavprioritetslås-venteindstillinger i SQL Server 2014 CTP1

  4. Kan jeg i MySQL udskyde kontrol af referenceintegritet, indtil commit