dbaspot
Tags Register FAQ Calendar Search Today's Posts Mark Forums Read

Sql Server 2005 Import Wizard - keep NULLS - sqlserver-dts

This is a discussion on Sql Server 2005 Import Wizard - keep NULLS - sqlserver-dts ; Hi, I have to import data from a flat file. There are some empty values in the flat file. When I import it using SQL 2000 Import Wizard, null values are correctly inserted in the table. However, using SQL Server ...


Home > Database Forum > Microsoft SQL Server > sqlserver-dts > Sql Server 2005 Import Wizard - keep NULLS

Reply

 

LinkBack (2) Thread Tools Display Modes
  2 links from elsewhere to this Post. Click to view. #1  
Old 11-05-2007, 09:34 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Sql Server 2005 Import Wizard - keep NULLS

Hi,

I have to import data from a flat file. There are some empty values in the
flat file.
When I import it using SQL 2000 Import Wizard, null values are correctly
inserted in the table.

However, using SQL Server 2005 Import wizard, empty strings (len(colName) is
zero) instead of nulls are being inserted.

How can I achieve the same results (keeping nulls) using the SQL Server 2005
Import Wizard?
Reply With Quote
  #2  
Old 11-06-2007, 06:02 AM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: Sql Server 2005 Import Wizard - keep NULLS

On Nov 6, 1:34 am, Mike Caceres Cace...@discussions.microsoft.com> wrote:
> Hi,
>
> I have to import data from a flat file. There are some empty values in the
> flat file.
> When I import it using SQL 2000 Import Wizard, null values are correctly
> inserted in the table.
>
> However, using SQL Server 2005 Import wizard, empty strings (len(colName) is
> zero) instead of nulls are being inserted.
>
> How can I achieve the same results (keeping nulls) using the SQL Server 2005
> Import Wizard?


Hi Mike,

Check the "RetainNulls" property on your File Source connection in
your data flow is set to True.

Good luck!
J

Reply With Quote
  #3  
Old 11-06-2007, 02:01 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: Sql Server 2005 Import Wizard - keep NULLS

J. thanks for the answer. Unfortunately I do not see that option in the
"Microsoft SQL Server Management Studio - Import and Export Wizard" when
setting the Data source to "Flat File".

Just to clarify, the empty values are delimited by, let's say two
consecutive TABS. The SQL 2000 import wizard will insert null in these cases.
The SQL 2005 import wizard will insert an empty string in these cases.

The reason for using this wizard (as oppossed to Bulk Insert) is because the
table columns could be in different order than the ones in the source text
files, or some columns in the text file needs to be skipped. I know I could
create a bcp format file, but I would like to avoid that route and keep
working with the Import wizard, if that is possible.

Thanks!

"jhofmeyr@googlemail.com" wrote:

> On Nov 6, 1:34 am, Mike Caceres > Cace...@discussions.microsoft.com> wrote:
> > Hi,
> >
> > I have to import data from a flat file. There are some empty values in the
> > flat file.
> > When I import it using SQL 2000 Import Wizard, null values are correctly
> > inserted in the table.
> >
> > However, using SQL Server 2005 Import wizard, empty strings (len(colName) is
> > zero) instead of nulls are being inserted.
> >
> > How can I achieve the same results (keeping nulls) using the SQL Server 2005
> > Import Wizard?

>
> Hi Mike,
>
> Check the "RetainNulls" property on your File Source connection in
> your data flow is set to True.
>
> Good luck!
> J
>
>

Reply With Quote
  #4  
Old 11-07-2007, 11:07 AM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: Sql Server 2005 Import Wizard - keep NULLS

On Nov 6, 6:01 pm, Mike Caceres
wrote:
> J. thanks for the answer. Unfortunately I do not see that option in the
> "Microsoft SQL Server Management Studio - Import and Export Wizard" when
> setting the Data source to "Flat File".
>
> Just to clarify, the empty values are delimited by, let's say two
> consecutive TABS. The SQL 2000 import wizard will insert null in these cases.
> The SQL 2005 import wizard will insert an empty string in these cases.
>
> The reason for using this wizard (as oppossed to Bulk Insert) is because the
> table columns could be in different order than the ones in the source text
> files, or some columns in the text file needs to be skipped. I know I could
> create a bcp format file, but I would like to avoid that route and keep
> working with the Import wizard, if that is possible.
>
> Thanks!
>
>
>
> "jhofm...@googlemail.com" wrote:
> > On Nov 6, 1:34 am, Mike Caceres > > Cace...@discussions.microsoft.com> wrote:
> > > Hi,

>
> > > I have to import data from a flat file. There are some empty values in the
> > > flat file.
> > > When I import it using SQL 2000 Import Wizard, null values are correctly
> > > inserted in the table.

>
> > > However, using SQL Server 2005 Import wizard, empty strings (len(colName) is
> > > zero) instead of nulls are being inserted.

>
> > > How can I achieve the same results (keeping nulls) using the SQL Server 2005
> > > Import Wizard?

>
> > Hi Mike,

>
> > Check the "RetainNulls" property on your File Source connection in
> > your data flow is set to True.

>
> > Good luck!
> > J- Hide quoted text -

>
> - Show quoted text -


Hi Mike,

I haven't really used the import wizard much, but I know that behind
the scenes it creates a SSIS package which is executed and discarded.
Presumably the wizard is hiding some of the functionality of the
package to make it easier to use, and in your case it is preventing
you from correctly setting the connection.

If I remember correctly, at the end of the wizard it asks if you want
to save the package instead of simply executing it immediately. I
would suggest you do this and then manually edit the package using
BIDS to set the file connection properties manually.

A little more leg-work, but well worth it as a basic introduction to
SSIS.
Good luck!
J

Reply With Quote
  #5  
Old 11-07-2007, 05:15 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: Sql Server 2005 Import Wizard - keep NULLS

Thank you J.

I tested this option (saving the package in the server, modifying it in BIDS
and executing the modified package) and it works well: it keeps the nulls.

I also found a simple workaround: keep using the old dtswiz.exe which also
keeps the nulls from the original text file.

Mike

"jhofmeyr@googlemail.com" wrote:

> On Nov 6, 6:01 pm, Mike Caceres
> wrote:
> > J. thanks for the answer. Unfortunately I do not see that option in the
> > "Microsoft SQL Server Management Studio - Import and Export Wizard" when
> > setting the Data source to "Flat File".
> >
> > Just to clarify, the empty values are delimited by, let's say two
> > consecutive TABS. The SQL 2000 import wizard will insert null in these cases.
> > The SQL 2005 import wizard will insert an empty string in these cases.
> >
> > The reason for using this wizard (as oppossed to Bulk Insert) is because the
> > table columns could be in different order than the ones in the source text
> > files, or some columns in the text file needs to be skipped. I know I could
> > create a bcp format file, but I would like to avoid that route and keep
> > working with the Import wizard, if that is possible.
> >
> > Thanks!
> >
> >
> >
> > "jhofm...@googlemail.com" wrote:
> > > On Nov 6, 1:34 am, Mike Caceres > > > Cace...@discussions.microsoft.com> wrote:
> > > > Hi,

> >
> > > > I have to import data from a flat file. There are some empty values in the
> > > > flat file.
> > > > When I import it using SQL 2000 Import Wizard, null values are correctly
> > > > inserted in the table.

> >
> > > > However, using SQL Server 2005 Import wizard, empty strings (len(colName) is
> > > > zero) instead of nulls are being inserted.

> >
> > > > How can I achieve the same results (keeping nulls) using the SQL Server 2005
> > > > Import Wizard?

> >
> > > Hi Mike,

> >
> > > Check the "RetainNulls" property on your File Source connection in
> > > your data flow is set to True.

> >
> > > Good luck!
> > > J- Hide quoted text -

> >
> > - Show quoted text -

>
> Hi Mike,
>
> I haven't really used the import wizard much, but I know that behind
> the scenes it creates a SSIS package which is executed and discarded.
> Presumably the wizard is hiding some of the functionality of the
> package to make it easier to use, and in your case it is preventing
> you from correctly setting the connection.
>
> If I remember correctly, at the end of the wizard it asks if you want
> to save the package instead of simply executing it immediately. I
> would suggest you do this and then manually edit the package using
> BIDS to set the file connection properties manually.
>
> A little more leg-work, but well worth it as a basic introduction to
> SSIS.
> Good luck!
> J
>
>

Reply With Quote
Reply

Thread Tools
Display Modes


LinkBacks (?)

LinkBack to this Thread: http://dbaspot.com/forums/sqlserver-dts/338931-sql-server-2005-import-wizard-keep-nulls.html

Posted By For Type Date
Flat File Import to new SQL Table > Small Business Server Support Forum - English > Smallbizserver.Net This thread Refback 04-30-2009 05:57 AM
Flat File Import to new SQL Table > Small Business Server Support Forum - English > Smallbizserver.Net This thread Refback 12-18-2008 01:02 PM


All times are GMT -4. The time now is 03:30 AM.