dbTalk Databases Forums  

Handling NULLs or blank values in incoming data

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Handling NULLs or blank values in incoming data in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Frango
 
Posts: n/a

Default Handling NULLs or blank values in incoming data - 09-14-2004 , 01:00 PM






Can anyone help with handling nulls or blank data being imported from foxpro
..dbf files into a normalized sql database? The data insert tasks are failing
because the normalization in sql server requires a value in the incoming
data, where this data was optional.

Thanks in advance...
Frango



Reply With Quote
  #2  
Old   
Krish
 
Posts: n/a

Default Re: Handling NULLs or blank values in incoming data - 09-14-2004 , 01:27 PM






why dont you check something like this

IF Trim(DTSSource("columnname")) <> "" Then
transform data
end if

"Frango" <f_gofa (AT) hotmail (DOT) com> wrote

Quote:
Can anyone help with handling nulls or blank data being imported from
foxpro
.dbf files into a normalized sql database? The data insert tasks are
failing
because the normalization in sql server requires a value in the incoming
data, where this data was optional.

Thanks in advance...
Frango





Reply With Quote
  #3  
Old   
Frango
 
Posts: n/a

Default Re: Handling NULLs or blank values in incoming data - 09-14-2004 , 02:00 PM



Thanks Krish,
I am going to try that, its just that I can't seem to find the correct
dialog in the DTS designer to accomplish this. If I create a new package
using the wizard, I can see where this would occur, but I, so far, have not
figured out where the corresponding dialog is accessed in the designer...

Frango

"Krish" <NOspam (AT) Nospam (DOT) org> wrote

Quote:
why dont you check something like this

IF Trim(DTSSource("columnname")) <> "" Then
transform data
end if

"Frango" <f_gofa (AT) hotmail (DOT) com> wrote in message
news:%23PPNUTomEHA.2616 (AT) tk2msftngp13 (DOT) phx.gbl...
Can anyone help with handling nulls or blank data being imported from
foxpro
.dbf files into a normalized sql database? The data insert tasks are
failing
because the normalization in sql server requires a value in the incoming
data, where this data was optional.

Thanks in advance...
Frango







Reply With Quote
  #4  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Handling NULLs or blank values in incoming data - 09-14-2004 , 05:42 PM



Does Foxpro support the syntax of something similar to

ISNULL(<col>,0)

i.e. If this col is NULL then substitute a 0.

And to get around the "" then you could do

NULLIF(<col>,"")

Combine them together and you get

ISNULL(NULLIF(<col>,""),0)


The solution offered by Krish I am not sure I understand but you would want
to use an Active Script transform and check for nulls there. If you find
one in the attribute then you could substitute a value instead.

Have a look on page 12 of this article

Building a Package in the DTS Designer
(http://www.sqldts.com/default.aspx?278)

--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.konesans.com - Consultancy from the people who know


"Frango" <f_gofa (AT) hotmail (DOT) com> wrote

Quote:
Thanks Krish,
I am going to try that, its just that I can't seem to find the correct
dialog in the DTS designer to accomplish this. If I create a new package
using the wizard, I can see where this would occur, but I, so far, have
not
figured out where the corresponding dialog is accessed in the designer...

Frango

"Krish" <NOspam (AT) Nospam (DOT) org> wrote in message
news:OQekzhomEHA.748 (AT) TK2MSFTNGP15 (DOT) phx.gbl...
why dont you check something like this

IF Trim(DTSSource("columnname")) <> "" Then
transform data
end if

"Frango" <f_gofa (AT) hotmail (DOT) com> wrote in message
news:%23PPNUTomEHA.2616 (AT) tk2msftngp13 (DOT) phx.gbl...
Can anyone help with handling nulls or blank data being imported from
foxpro
.dbf files into a normalized sql database? The data insert tasks are
failing
because the normalization in sql server requires a value in the
incoming
data, where this data was optional.

Thanks in advance...
Frango









Reply With Quote
  #5  
Old   
Jamie Carper
 
Posts: n/a

Default RE: Handling NULLs or blank values in incoming data - 11-18-2004 , 01:09 PM



Let me add to this that the reason for this custom transform is because the
CSV data contains periods Chr(46) inplace of the NULL values Chr(0). I want
to preserve any NULL values in the data sets imported.

"Jamie Carper" wrote:

Quote:
I have a data transformation where the source column is a number value from a
comma delimited text file and the destination column is to a SQL table where
the field is an integer type that accepts NULL values.

Given the example code below I should be able to complete the above
transformation. Using the "TEST" option within the ActiveX Script object it
works without a single error.

However when I attempt to execute the Transformation object of which calls
the code below, I get the following error: "...invalid data value for
'Col007' destination column".

'************************************************* *******
Function Main()
DTSDestination("Col007") = Replace(DTSSource("Col007"), Chr(46), Chr(0))
Main = DTSTransformStat_OK
End Function
'************************************************* *******

Also I get the same error message if I use "" instead.

I cannot seem to find a workaround for what seems to me to be a bug in the
DTS.

Can anyone offer up a solution? I cannot alter the incoming data prior to
the import.

Reply With Quote
  #6  
Old   
Jamie Carper
 
Posts: n/a

Default RE: Handling NULLs or blank values in incoming data - 11-18-2004 , 01:09 PM



I have a data transformation where the source column is a number value from a
comma delimited text file and the destination column is to a SQL table where
the field is an integer type that accepts NULL values.

Given the example code below I should be able to complete the above
transformation. Using the "TEST" option within the ActiveX Script object it
works without a single error.

However when I attempt to execute the Transformation object of which calls
the code below, I get the following error: "...invalid data value for
'Col007' destination column".

'************************************************* *******
Function Main()
DTSDestination("Col007") = Replace(DTSSource("Col007"), Chr(46), Chr(0))
Main = DTSTransformStat_OK
End Function
'************************************************* *******

Also I get the same error message if I use "" instead.

I cannot seem to find a workaround for what seems to me to be a bug in the
DTS.

Can anyone offer up a solution? I cannot alter the incoming data prior to
the import.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.