Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old December 10th, 2004, 05:08 PM
ddavies ddavies is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 6 ddavies User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 42 m 19 sec
Reputation Power: 0
SQL in DTS Package

The SQL that I want to execute for one step in my package
is as follows:

DELETE
FROM DB1.dbo.Table1
WHERE load_id IN
(SELECT load_id
FROM DB2.dbo.Table2
WHERE (month_id = ?);

? = a value from a global variable.

When I try to do this in a straight forward manner using an
"Execute SQL" task, I get an error saying that you can't have
a parameter in a sub query.

If I try to do it creating a temptable with the following code
it gives me an error because (I think)the temp table doesn't exist yet.

Create Table #dummy (load_id INT);

INSERT INTO #dummy
SELECT load_id
FROM DB2.dbo.Table2
WHERE (month_id = ?);

DELETE
FROM DB1.dbo.Table1
WHERE load_id in (select load_id from #dummy);

The only way that I can get this to work is using the Data Driven
Query Task which seems like overkill for this application.

Any ideas on how to do this directly in the "Execute SQL" task?

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > SQL in DTS Package


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway