Home Forums SQL Server 7,2000 T-SQL Find Affected Row Count from a Dynamic Query RE: Find Affected Row Count from a Dynamic Query

  • I did.

    DECLARE @sSQL NVARCHAR(100), @rowcount INT

    SET @sSQL = 'select * from sysobjects'

    EXEC sp_executesql @sSQL

    SELECT @rowcount = @@ROWCOUNT

    PRINT '@rowcount = ' + CAST(@rowcount AS VARCHAR(4))

    Output in the messages tab -

    (118 row(s) affected)

    @rowcount = 118

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass