Export a dataset with optional columns to database

On the forum there are answered questions regarding optional columns. Here is one of them: