Bet you wouldn't of read this if there was a VB prefix.
There are two reasons why I did this:
1. Writing a VB script got me money. Courtesy of a bet.
2. This is my answer to those people who ask me to reupload this file. Instead of MySQL it's PostgreSQL.
Please note: This only copies tables, primary keys, indexes and data. Foreign keys cannot be copied at this time.
You are required to have PostgreSQL ODBC driver installed, which can be found here.
This script has a few parameters that determine its operation, they are listed below.
Wrapped lines have a \ at the end and the following line is indented.Quote:
Flags:
-c create structure only, no data copy, default false
-f flush destination of duplicate tables before creating, default false
-l turns table and colum names to lowercase
-p pretend, prints the SQL output, default false
-t time myself and report stats, default false
-v makes verbose, default false
Parameters:
/shostname:[source hostname, default localhost)
/sdatabase:[source database name, required]
/susername:[source connection username, default sa]
/spassword:[source connection password, default blank]
/dhostname:[destination hostname, default localhost]
/ddatabase:[destination database, default sdatabase]
/dusername:[destination connection username, default postgres]
/dpassword:[destination connection password, default blank]
/table:[tablename]
Example:
If the source database uses any of the nchar, ntext or nvarchar field types the destination database must support UTF8 encoding.Code:# Migrate the database `clients` verbosely
C:\>cscript migration.vbs -v /sdatabase:clients /dhostname:db.mydomain.com
# Convert the database `clients` verbosely, with specific users
C:\>cscript migration.vbs -v /sdatabase:clients /susername:dba /spassword:fr43ed \
/dhostname:db.mydomain.com /dusername:webdb /dpassword:simple
# Copy the database, new name or into existing database
C:\>cscript migration.vbs -v /sdatabase:clients /dhostname:db.mydomain.com \
/ddatabase:big_master
# Copy from one server with one name to another server with another name
C:\>cscript migration.vbs /shostname:192.168.1.56 /sdatabase:clients \
/dhostname:192.168.1.65 /ddatabase:big_master
This script cannot handle all of the data types. While running if the script encounters one of these data types it will halt.
Invalid data types:
binary
decimal
image
sql_variant
timestamp
uniqueidentifier
varbinary
