Automating SQL Packager tutorial

chris sampsonchris sampson Posts: 38
edited November 26, 2004 7:48AM in SQL Packager Previous Versions
Hi there,

We are currently investigating this problem and will get back to you as soon as possible.
Chris Sampson
Support Engineer
Red Gate Software

Comments

  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hi Adam,

    There is a bit of a bad assumption in the automating SQL Packager tutorial code that you are not going to package a table which contains a BLOB column such as text or image. Since Packager requires a primary key on the table in order to properly index the BLOB data, setting the primary key fields in the TableComparisonSetting to NULL will not work with tables containing binary data. What I think is a good idea, then, is to add a conditional statement to the code to allow for this because you want to use a primary key if it's available but you want to avoid another NULL-reference exception if it isn't.

    Please change this bit of code in the Packager example:
    foreach (RedGate.SQLDataCompare.Engine.Table table in database2.Tables)
    			{
    				//since we are always inserting data there is no need to define a primary key
    				tablesToCompare.Add(new RedGate.SQLDataCompare.Engine.TableComparisonSetting(table.FullyQualifiedName, table.Fields, null));
    			}
    

    To this:
    foreach (RedGate.SQLDataCompare.Engine.Table table in database2.Tables)
    
    {
    
    //since we are always inserting data there is no need to define a primary key unless there are binary data columns!
    
    if (table.PrimaryKey != null) tablesToCompare.Add(new RedGate.SQLDataCompare.Engine.TableComparisonSetting(table.FullyQualifiedName, table.Fields, table.PrimaryKey.Fields));
    
          else tablesToCompare.Add(new RedGate.SQLDataCompare.Engine.TableComparisonSetting(table.FullyQualifiedName, table.Fields, null));
    
          }
    
This discussion has been closed.