dbTalk Databases Forums  

Insert problem

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


Discuss Insert problem in the microsoft.public.sqlserver.dts forum.



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

Default Insert problem - 11-17-2005 , 03:07 PM






Hello Everyone.

I basically want to do an insert.

Here's my insert script which works when the database is empty.
In the destination table i created another index (siteid).

' Copy each source column to the destination column
Function Main()
DTSDestination("wexchid") = DTSSource("exchid")
DTSDestination("wexTitle") = DTSSource("exTitle")
DTSDestination("wexSku") = DTSSource("exSku")
DTSDestination("wexDescription") = DTSSource("exDescription")
DTSDestination("wexPrice") = DTSSource("exPrice")
DTSDestination("wexPrice2") = DTSSource("exPrice2")
Main = DTSTransformStat_InsertQuery
End Function

I don't know how to check if the DTSDestination("wexSku") exist.
If it does exist then skip that row during an insert.

If i was writing this in normal asp then it won't be an issue but i'm
struggling here.

Would it be just to write someting like this

If (DTSLookups("skuCHECK").Execute(DTSSource("wexSku" ))) Then
Main = DTSTransformStat_InsertQuery
End If


My lookup checks the destination table and then matches it with the source.

I need some help here.

Thank you

April




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

Default Re: Insert problem - 11-17-2005 , 03:39 PM






Yep you can certainly do that.

Have you thought about linked servers?




Allan

"Best Practice" <aprilfool2005 (AT) gmail (DOT) com> wrote


Quote:
Hello Everyone.

I basically want to do an insert.

Here's my insert script which works when the database is empty.
In the destination table i created another index (siteid).

' Copy each source column to the destination column
Function Main()
DTSDestination("wexchid") = DTSSource("exchid")
DTSDestination("wexTitle") = DTSSource("exTitle")
DTSDestination("wexSku") = DTSSource("exSku")
DTSDestination("wexDescription") = DTSSource("exDescription")
DTSDestination("wexPrice") = DTSSource("exPrice")
DTSDestination("wexPrice2") = DTSSource("exPrice2")
Main = DTSTransformStat_InsertQuery
End Function

I don't know how to check if the DTSDestination("wexSku") exist.
If it does exist then skip that row during an insert.

If i was writing this in normal asp then it won't be an issue but i'm
struggling here.

Would it be just to write someting like this

If (DTSLookups("skuCHECK").Execute(DTSSource("wexSku" ))) Then
Main = DTSTransformStat_InsertQuery
End If


My lookup checks the destination table and then matches it with the
source.

I need some help here.

Thank you

April


Reply With Quote
  #3  
Old   
Best Practice
 
Posts: n/a

Default Re: Insert problem - 11-17-2005 , 08:02 PM



The databases are all on the same server.

When i run the package it bombs out.

I'm i missing something simple????

Please any feed back would be appreciated.

April


"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote

Quote:
Yep you can certainly do that.

Have you thought about linked servers?




Allan





Reply With Quote
  #4  
Old   
Best Practice
 
Posts: n/a

Default Re: Insert problem - 11-17-2005 , 08:15 PM



I'm having a syntax error day here...any suggestions.


' Copy each source column to the destination column
Function Main()
DTSDestination("wexchid") = DTSSource("exchid")
DTSDestination("wexTitle") = DTSSource("exTitle")
DTSDestination("wexSku") = DTSSource("exSku")
DTSDestination("wexDescription") = DTSSource("exDescription")
DTSDestination("wexPrice") = DTSSource("exPrice")
DTSDestination("wexPrice2") = DTSSource("exPrice2")

If (DTSLookups("skuCHECK").Execute(DTSSource("exSku") )) Then
Main = DTSTransformStat_InsertQuery
End If

End Function


The lookup is set to check the destination against the source.

I guess this is where my problems lies.

If "what goes in here"
(DTSLookups("skuCHECK").Execute(DTSSource("exSku") )) Then


I'm stuck any help would be appreciated.

April




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

Default Re: Insert problem - 11-18-2005 , 12:39 AM



If the databases are on the same server then do not use lookups.

How about you simply say

INSERT TABLE(COLUMNS)
SELECT (COLUMNS)
FROM DATABASE.OWNER.TABLE DB1 LEFT OUTER JOIN dbo.TABLE T1
ON DB1.(Id Columns) =T1.id Column)
WHERE T1.(Is Column IS NULL)

Obviously you will need to play with the syntax for your environment.
This then would site in an ExecuteSQL Task

If you did this

SELECT (COLUMNS)
FROM DATABASE.OWNER.TABLE DB1 LEFT OUTER JOIN dbo.TABLE T1
ON DB1.(Id Columns) =T1.id Column)
WHERE T1.(Is Column IS NULL)

You could use a DataPump task


You say "Bombs Out". With what error?


"Best Practice" <aprilfool2005 (AT) gmail (DOT) com> wrote


Quote:
I'm having a syntax error day here...any suggestions.


' Copy each source column to the destination column
Function Main()
DTSDestination("wexchid") = DTSSource("exchid")
DTSDestination("wexTitle") = DTSSource("exTitle")
DTSDestination("wexSku") = DTSSource("exSku")
DTSDestination("wexDescription") = DTSSource("exDescription")
DTSDestination("wexPrice") = DTSSource("exPrice")
DTSDestination("wexPrice2") = DTSSource("exPrice2")

If (DTSLookups("skuCHECK").Execute(DTSSource("exSku") )) Then
Main = DTSTransformStat_InsertQuery
End If

End Function


The lookup is set to check the destination against the source.

I guess this is where my problems lies.

If "what goes in here"
(DTSLookups("skuCHECK").Execute(DTSSource("exSku") )) Then


I'm stuck any help would be appreciated.

April


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.