The key issue here is not math, it is units. Your equation for escape velocity seems to be correct, as per Wikipedia.
$$v_\text{escape}=\sqrt{2GM \over R}=\sqrt{{2\left(6.674\times 10^{-11} {\text{m}^3\over{\text{kg}\cdot s^2}}\right)\left(1 M_{\odot} \right)}\over{\left(1\times 10^4 \text{ km}=1\times10^7 \text{ m}\right)}}$$ This converts to: $$3.653\times 10^{-9} \sqrt{\mathbf{{m^3 M_{\odot}}\over{\text{m}\cdot \text{kg} \cdot \text{s}^2}}}$$ This is technically correct, but we can convert solar mass ($M_\odot$) to $\text{kg}$ by the following conversion: $1 M_\odot = 1.989\times 10^{30} \text{ kg}$.
Note that we will multiply the number by the square root of the relationship, since we factored out the square root. So the final answer is: $$5.152\times 10^6 \sqrt{\mathbf{\text{m}^2 \over \text{s}^2}}$$ $$5.152\times 10^{6} \mathbf{m\over{s}}$$