Script to merge-replicate two MDF database files? I have a program on a computer and on a tablet. The program uses SQL Server Express to interact with a local database (the same information on both) from a .MDF file. So if I plug the tablet into the PC, I have two .MDF files that I want to synchronize.

I want both users to be able to make changes to the version on their device, then I want to get both .MDF files and run a script that merges them. 

The database has a GUID primary key, and a DateTime of when it was last changed, so if there are conflicts, I would just take the most recent version.

How should I do this? 

Or alternatively, if I'm going about this the wrong way, could you recommend an alternative way to keep the databases of these two machines synchronized without an internet connection?

Thanks in advance.
Without an internet connection, you would be looking at merge or peer-to-peer replication. Neither of which can be implemented easily (google I seem to remember seeing a workaround somewhere) how you want with Express edition. If you had standard or better edition I would personally go with Peer-To-Peer as it negates the need for an additional column per table and like merge includes conflict resolution. Be advised though that in my opinion replication is a fairly finicky technology and requires intermediate DBA skills to implement and troubleshoot efficiently. Also be advised that once replication is implimented that no transaction can be cleared by a transaction log backup or checkpoint (depending on your recovery model) until it has been distributed to its subscriber. Depending on the duration and number of commands between syncs this will cause your transaction log to grow and potentially fill the disk. Obviously if the avilable disk space becomes full no new transactions can be written / updated in the DB.

With an internet connection I would definitely look at Azure to give you a single database which both devices can write to. 

Obviously you can also look to pull and merge the data via powershell, SSIS, C# scripts or get a trial licence of RedGate data compare and kick off via a windows scheduled task (SQL Server agent is not available in express) and do the job which replication would do out of the box.

On a side note depending on your usage you might be able to get hold of developer edition SQL Server licence which is equal to enterprise.

Edit 1: peer to peer is an enterprise only feature in 2008r2 and 2012 at least, unlike merge which is available in standard