I have not had this problem in Sonar but doesn't 8 have this fixed?
Below is from the Help file New features.
MIDI out port assignments are retained when adding/removing MIDI devices
--------------------------------------------------------------------------------
In SONAR 8, MIDI tracks and control surfaces retain their current MIDI output port assignments if you add or remove MIDI devices.
Changing output ports in the MIDI Devices dialog
Changing MIDI output ports in the MIDI Devices dialog has the following effect:
Enabling a new output port. All MIDI tracks and control surfaces retain their current output port assignments.
Disabling an unassigned output port. All MIDI tracks and control surfaces retain their current output port assignments.
Disabling an assigned output port. The result is different for MIDI tracks and control surfaces:
MIDI tracks. The Missing MIDI Ports dialog appears and lets you remap the missing output ports to available output ports.
Note: If you do not remap a missing device, the track's Output control will display MISSING: <name of missing device>. If the missing device becomes available in the future, the track will automatically be assigned to the correct device.
Control surfaces. The control surface output port is assigned to None.
Figure 9. The Missing MIDI Ports dialog lets you remap missing output devices
Figure 10. A track's Output control shows the name of the missing device
Opening projects after MIDI configuration has changed
If any assigned MIDI output devices are missing when you load a project, which is likely to happen if you transfer projects between different computers, SONAR will do the following:
MIDI tracks. The Missing MIDI Ports dialog appears and lets you remap the missing devices to available devices.
Note: If you do not remap a missing devices, the track's Output control will display MISSING: <name of missing device>. If the missing device becomes available in the future, the track will automatically be assigned to the correct device.
Control surfaces. Control surface output ports are assigned to None.