There is a direct train Stockholm-Copenhagen and then Copenhagen-Hamburg. Just hope you don't run into some unforeseen disruption.
Edit: Looking at bahn.de, I found a direct train from Stockholm to Hamburg,[1] no need for a change in Copenhagen. There was also an option to change in Malmö instead of Copenhagen.