• DECLARE @sql varchar(max)

    SET @sql = 'Update '+ @baseTable +' set Quantity = s.Quantity

    from ' + @baseTable +' p , '+ @stageTbl +' s

    where p.TimeKey = s.TimeKey and p.AccountId = s.AccountId and p.StockId=s.StockId'

    EXEC (@sql)



    Praveen D'sa
    MCITP - Database Administrator 2008
    http://sqlerrors.wordpress.com