Hello sam 55243,
Instead of writing code for this problem, I advice you to use SSMA (SQL Server Migration Assistant)
This is a free tool provided by Microsoft for Migration purpose from various database servers to MS SQL Server
You can find much information on this link
Hope this will be helpful to you
Thanks.....:-)