@itimpi, eschwartz, BetterRed: thanks for your responses!
I have proceeded like BetterRed and itimpi suggested and it has worked like I wanted. The main points for me were:
1. Choose "Switch/create library"
2. Enter the path of the A library
3. Choose the first option ("Use the the previously existing library ...")
4. Highlight all books
5. Choose "Copy to library" B
Calibre also asked me if I want to add the columns of A library in B library which of course I did. So everything is fine now!