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 April 13th, 2004, 07:30 AM
JamieKnowles JamieKnowles is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 3 JamieKnowles User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 35 sec
Reputation Power: 0
DTS: Output file, except when no records

Hi,

I have a DTS package which exports the records in a view into a CSV file.

However, when the view returns no records, the DTS package outputs a blank csv file.

There must be a way of preventing this, i only want the file to be created if there are records in the view.

Any ideas??

Reply With Quote
  #2  
Old April 13th, 2004, 09:19 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,776 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 27 m 42 sec
Reputation Power: 470
you would need to write a script that checks if records were returned from the view, if there are records then run the DTS package.

Reply With Quote
  #3  
Old April 13th, 2004, 11:25 AM
JamieKnowles JamieKnowles is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 3 JamieKnowles User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 35 sec
Reputation Power: 0
Thanks for the reply.

I did try that, but apparently VB script is different from VB??

As my code that runs fine in VB just returns a multitude of errors when i try to enter it into an Active X Script Task.

The views name is '01_ReceivingsNotSent', any chance you could suggest what the code would be, or point me in the direction of a good VB scriping site, it cant be THAT different from VB.

Reply With Quote
  #4  
Old April 13th, 2004, 03:17 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,776 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 27 m 42 sec
Reputation Power: 470
You can do it something like this
Code:
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Your ConnectionString"

Set rs = Conn.Execute("SELECT COUNT(*) As 'count' FROM ViewName")

if rs.count > 0 Then
   there are records, so run the dts package
   const DTSSQLStgFlag_Default = 0 
   const DTSStepExecResult_Failure = 1
   Set oPkg = Server.CreateObject("DTS.Package")
   blnSucceeded = True

   
   LoadFromSQLServer ServerName, Username, Password, Flags, PackagePassword, PackageGUID, PackageVersionGUID, Package Name, PersistsHost

   oPkg.LoadFromSQLServer "(local)", "sa", "", DTSSQLStgFlag_Default, "", "", "", "DTSPackageName", ""
   oPkg.Execute

   for each oStep in oPkg.Steps 
      if oStep.ExecutionResult = DTSStepExecResult_Failure then 
         strResult = strResult & "Package " & oStep.Name & " failed.<br>" 
         blnSucceeded = false 
      else 
         strResult = strResult & "Package " & oStep.Name & " succeeded.<br>" 
      end if 
next 

if blnSucceeded then 
   Response.Write "<h1>Package Succeeded</h1>" 
else 
   Response.Write "<h1>Package Failed</h1>" 
end if 

Response.Write strResult 

Reply With Quote
  #5  
Old April 14th, 2004, 05:39 AM
JamieKnowles JamieKnowles is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 3 JamieKnowles User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 35 sec
Reputation Power: 0
Thats fantastic, thanks soooooo much

Problem is now sorted.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > DTS: Output file, except when no records


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 3 hosted by Hostway
Stay green...Green IT