dbTalk Databases Forums  

if statement and null values

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


Discuss if statement and null values in the microsoft.public.sqlserver.dts forum.



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

Default if statement and null values - 10-08-2003 , 04:26 PM






I create a DTS package that will transfer the new records
and updated records from sql server on a web server to
our internal Access database.

Step1 is to use create a global varible

SELECT MAX(updateDate) AS glbMaxDate
FROM Results

step 2 is to delete the records in Results table.

step 3 is to transfer those records in SQL server >
parameter glbMaxDate to Access database.

I create this as a daily routine job. My question is I
found if there is no new or updated records, then no
records will be moved to Access tables, and for step 2 in
last run deleted all the records, so next time the job
runs,

SELECT MAX(updateDate) AS glbMaxDate
FROM Results

will turn to null.

when job runs to step 3,it gives error message: invalid
input parameter value
How can I solve this problme, should I use a if statement,
what is the syntax about that?

Thanks for any suggestions in advance.



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

Default Re: if statement and null values - 10-08-2003 , 04:33 PM






Why do you grab a value from the Results table and then delete from it ?

I presume the records you move are based on the value retrieved from the
results table ?


--
--

Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org

"Ann" <xiaowei.cao (AT) state (DOT) mn.us> wrote

Quote:
I create a DTS package that will transfer the new records
and updated records from sql server on a web server to
our internal Access database.

Step1 is to use create a global varible

SELECT MAX(updateDate) AS glbMaxDate
FROM Results

step 2 is to delete the records in Results table.

step 3 is to transfer those records in SQL server
parameter glbMaxDate to Access database.

I create this as a daily routine job. My question is I
found if there is no new or updated records, then no
records will be moved to Access tables, and for step 2 in
last run deleted all the records, so next time the job
runs,

SELECT MAX(updateDate) AS glbMaxDate
FROM Results

will turn to null.

when job runs to step 3,it gives error message: invalid
input parameter value
How can I solve this problme, should I use a if statement,
what is the syntax about that?

Thanks for any suggestions in advance.





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

Default Re: if statement and null values - 10-09-2003 , 09:59 AM



Yes,this is a scheduled daily job. I grab the value of Max
(date) in result table in Access database and save in a
global variable. Then I delete all the records in the
result table. Because I only want the new data from SQL
server, so I select all new data in SQLserver which is
Quote:
Max(date), and transfer to result table.
Result table always has 'today''s new data.
Result table is a staging table. I will do some
manupilation of checking, then goes to the destination
table in the same Access database.

Am I correct on the way?

Thanks

Quote:
-----Original Message-----
Why do you grab a value from the Results table and then
delete from it ?

I presume the records you move are based on the value
retrieved from the
results table ?


--
--

Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org

"Ann" <xiaowei.cao (AT) state (DOT) mn.us> wrote in message
news:25c0201c38de2$cdafed50$a601280a (AT) phx (DOT) gbl...
I create a DTS package that will transfer the new
records
and updated records from sql server on a web server to
our internal Access database.

Step1 is to use create a global varible

SELECT MAX(updateDate) AS glbMaxDate
FROM Results

step 2 is to delete the records in Results table.

step 3 is to transfer those records in SQL server
parameter glbMaxDate to Access database.

I create this as a daily routine job. My question is I
found if there is no new or updated records, then no
records will be moved to Access tables, and for step 2
in
last run deleted all the records, so next time the job
runs,

SELECT MAX(updateDate) AS glbMaxDate
FROM Results

will turn to null.

when job runs to step 3,it gives error message: invalid
input parameter value
How can I solve this problme, should I use a if
statement,
what is the syntax about that?

Thanks for any suggestions in advance.




.


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

Default Re: if statement and null values - 10-09-2003 , 10:26 AM



Do you only want NEW records not Altered ?

You can either

If you import daily then you can take over

SELCT <<col list>> FROM TABLE WHERE CONVERT(CHAR(8),DateField,112) =
CONVERT(CHAR(8),Getdate()-1,112)

OR

Add a trigger to the Source table and INSERT into a staging table. At the
end of the day, week, month you can then DTS over only this table. You
clear it down after import.



--
--

Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org

"Ann" <xiaowei.cao (AT) state (DOT) mn.us> wrote

Quote:
Yes,this is a scheduled daily job. I grab the value of Max
(date) in result table in Access database and save in a
global variable. Then I delete all the records in the
result table. Because I only want the new data from SQL
server, so I select all new data in SQLserver which is
Max(date), and transfer to result table.
Result table always has 'today''s new data.
Result table is a staging table. I will do some
manupilation of checking, then goes to the destination
table in the same Access database.

Am I correct on the way?

Thanks

-----Original Message-----
Why do you grab a value from the Results table and then
delete from it ?

I presume the records you move are based on the value
retrieved from the
results table ?


--
--

Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org

"Ann" <xiaowei.cao (AT) state (DOT) mn.us> wrote in message
news:25c0201c38de2$cdafed50$a601280a (AT) phx (DOT) gbl...
I create a DTS package that will transfer the new
records
and updated records from sql server on a web server to
our internal Access database.

Step1 is to use create a global varible

SELECT MAX(updateDate) AS glbMaxDate
FROM Results

step 2 is to delete the records in Results table.

step 3 is to transfer those records in SQL server
parameter glbMaxDate to Access database.

I create this as a daily routine job. My question is I
found if there is no new or updated records, then no
records will be moved to Access tables, and for step 2
in
last run deleted all the records, so next time the job
runs,

SELECT MAX(updateDate) AS glbMaxDate
FROM Results

will turn to null.

when job runs to step 3,it gives error message: invalid
input parameter value
How can I solve this problme, should I use a if
statement,
what is the syntax about that?

Thanks for any suggestions in advance.




.




Reply With Quote
  #5  
Old   
xiaowei cao
 
Posts: n/a

Default Re: if statement and null values - 10-09-2003 , 10:31 AM





Yes,this is a scheduled daily job. I grab the value of Max(date) in
result table in Access database and save in a global variable. Then I
delete all the records in the result table. Because I only want the new
data from SQL server, so I select all new data in SQLserver which is
Quote:
Max(date), and transfer to result table.
Result table always has 'today''s new data.
Result table is a staging table. I will do some manupilation of
checking, then goes to the destination table in the same Access
database.

Am I correct on the way? And if correct, can you help me with my first
posting questions?

Thanks in advance


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Reply With Quote
  #6  
Old   
xiaowei cao
 
Posts: n/a

Default Re: if statement and null values - 10-09-2003 , 10:31 AM





Yes,this is a scheduled daily job. I grab the value of Max(date) in
result table in Access database and save in a global variable. Then I
delete all the records in the result table. Because I only want the new
data from SQL server, so I select all new data in SQLserver which is
Quote:
Max(date), and transfer to result table.
Result table always has 'today''s new data.
Result table is a staging table. I will do some manupilation of
checking, then goes to the destination table in the same Access
database.

Am I correct on the way? And if correct, can you help me to figure out
my first posting question?


Thanks in advance


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Reply With Quote
  #7  
Old   
xiaowei cao
 
Posts: n/a

Default Re: if statement and null values - 10-09-2003 , 12:45 PM





I do need both new records and altered records.
So does what you suggested apply to my situation too?

I'm new to SQL server, please help

Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

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

Default Re: if statement and null values - 10-09-2003 , 03:03 PM



Yes.

I personally would use a trigger on the Source. It will capture the
changes/additions to the table and the row values. You can then apply then
using the DDQ.

I have a package from a presentation I gave at Reading if you mail me
privately which does the kind of thing I would do in your situation.

--
--

Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org

"xiaowei cao" <xiaowei.cao (AT) state (DOT) mn.us> wrote

Quote:

I do need both new records and altered records.
So does what you suggested apply to my situation too?

I'm new to SQL server, please help

Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Reply With Quote
  #9  
Old   
xiaowei cao
 
Posts: n/a

Default Re: if statement and null values - 10-10-2003 , 11:28 AM




Thanks, Allan
I'm new to SQL server, and I tried to learn how to use DTS, it's good to
have some sample packages. I checked in SQl server there is only one
Demo package example.

Where can I look at more dts package samples.
You mentioned you have a presentation package example, how can I reach
you, can you send me an email with it?

my email address is xiaowei.cao (AT) state (DOT) mn.us

Thanks again

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

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

Default Re: if statement and null values - 10-10-2003 , 04:01 PM



On it's way

--
--

Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org

"xiaowei cao" <xiaowei.cao (AT) state (DOT) mn.us> wrote

Quote:
Thanks, Allan
I'm new to SQL server, and I tried to learn how to use DTS, it's good to
have some sample packages. I checked in SQl server there is only one
Demo package example.

Where can I look at more dts package samples.
You mentioned you have a presentation package example, how can I reach
you, can you send me an email with it?

my email address is xiaowei.cao (AT) state (DOT) mn.us

Thanks again

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



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.