Home Forums SQL Server 7,2000 T-SQL Inserting a record count using Dynamic SQL RE: Inserting a record count using Dynamic SQL

  • quote alternative method for placing the record count from a table into a variable

    DECLARE @sql nvarchar(100),@Reccount int

    SET @sql = 'SELECT COUNT(*) FROM InterchangeDTA.dbo.' + @TableName

    EXECUTE sp_executesql @sql, N'@Reccount int output', @Reccount output

    Then you can insert

    INSERT INTO TableCounter (TableName) VALUES @Reccount

    btw, you state TableName as the column for insert but use the count as data! Is this right?

    Far away is close at hand in the images of elsewhere.
    Anon.