The only certain freedom's in departure. (Robert Frost)
Every journey begins in Copenhagen!
At least mine...
There is at least one more good and simple possibility, but let's start with Copenhagen as it is very easy to explain.
Either you go by a night train from Copenhagen, or you travel to Hamburg and board your night train there - as simple as that!
But fortunately there are some options to consider - otherwise it wouldn't be funny at all...
With the City Night line, that leaves a few minutes before 19.00 (at the moment 18.40 - but watch out some days earlier), you may go straight to Amsterdam, Prague or Basel SBB (the Swiss side) without changing trains. A few years ago this was also possible to Munich, but for some reason this option is gone. Now you have to travel with the cars bound for Basel, and switch in Fulda, resulting in a somewhat overcrowded Basel part.
These trains pass many stations on its way to their destinations, giving plenty of opportunities to combine with other trains. More of that in the "Night train" and "Routes" sections. It can also be a bit tricky to find the best price and to tailor your route - I will deal with these problems in the "Booking" and "Routes" sections as well.
If you travel with an earlier train to Hamburg, you may choose from a lot of night trains criss-crossing Europe. There are also some regular Inter City and Inter City Express running at night.
To get to Hamburg you may go with a Euro city train or an Inter City Express passing Rödby-Puttgarden (ferry crossing).
The ferry crossing is fun the firts time, the second and maybe the third...
It could be a good idea to occasionally choose the way over Flensburg - passing the Stora and Lilla Bält (on bridges and in tunnels) - and the bridge over Kiel Channel/Kaiser Wilhelm kanal (the City night line travels this way as well, but then it's dark night). It is a remarkable bridge, and I have som pictures in the galleies.
You travel (mostly) with an Inter City train to Flensburg and then with a regional train to Hamburg.
Well, now you are at least in Hamburg. Let me just make a note about the connecting trains in Copenhagen.
The City Night Line and the swedish trains to Copenhagen are notoriously delayed!
The common advice is that you plan at least one hour or so as switching time.
If you want to be on the safe side this is not enough!
It is far better to plan for a "good meal" and a coffe in Copenhagen- it is really a pain sitting on a swedish train and see the seconds ticking away, knowing that the City Night Line is your last and only option. My suggestion is at least two hours swiching time - then you'll have time enough for something to eat and/or tangling schedules.
There is also a night train between Malmö and Berlin - the route is Malmö-Trelleborg-Sassnitz-Berlin. Between Trelleborg and Sassnitz you will go with a train-ferry, and that is also the reason why this "short" trip lasts so long.
The advantage is that this train leaves Malmö at late evening which makes it possible to catch even if you must travel a long way in Sweden. This is of course the case also in the opposite direction.
But there are several disadvantages, such as a "peculiar" schedule. It isn't a daily tran, and it is difficult to fit in in your plans, especially off-season . There is more information in the "night train" section.
If a night train trip to Berlin seems tempting, note that the City Night Line Copenhagen - Praha also passes Berlin (and Dresden).