The dance-off between Officer Joe Marte and 5-year-old Colten Guerra was caught on video and posted it on YouTube.
The hospital is treating the Brentwood boy for an aggressive form of cancer, neuroblastoma.
Marte said he saw a fundraising advertisement for Colten and decided to visit him on his day off.
"Colten's mom saw an old video of me break dancing and I congratulated him on one of his break dancing videos his mom posted. And, of course, Colten wasted no time in challenging me and of course I couldn't resist," Marte said.
His family says the interaction with the man in blue made his day.