Secondary dominants

The dominant note in a scale is the fifth note of that scale.

The C major scale consists of the notes C D E F G A B. In C Major, G would be the dominant or fifth note. The tonic note in a scale is the first note of that scale, in C Major C would be tonic. The secondary dominant is the the dominant of the dominant or the five-of-five. If you begin in C major the secondary dominant would be D, which is the dominant of G.

However the scale that begins and ands on D in the key of C major is a minor one (actually, it is known as the 'dorian' mode WWHWWHW [W=Whole tone/Maj 2nd, H=half tone/min 2nd]).

So to strengthen the 'dominant effect', we raise the F one half step to F# (not coincidentally this is the 'leading tone' for the root of the next intended chord: G) Thus creating a major chord which has a strong harmonic tendency to resolve to the G major chord that is functioning as the dominant in the key of C major. This is one of the natural ways that accidentals can occur and is not considered in itself a full 'modulation'.

The secondary dominant can be used to prepare chords on other 'degrees' of the scale as well; the tonic, with the addition of the lowered 7th degree, is often used as the dominant of the sub-dominant etc.