You cannot use a query to do this. You may want to write some script to do this, or export your data to a csv and import. The other option is to backup and try to restore it onto the new server. Once it is restored you will have full access to all the data.
if you want to transfer data from one server to another, you can use Database Publishing Wizard software by using this you can make a script of database with table and insert query with data, you had stored in that.
now mostly server support query interface, you can simple copy the content from the script to server query interface and transfer your data from one server to another.