Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 forcing a SQL Task to Fail

Author  Topic 

aleedy
Starting Member

2 Posts

Posted - 2002-03-12 : 17:49:17
in a dts package, i am importing data into a temp table. I am then using a sql task to compare the temp table with another table to check for dups. If dups exists (@@ROWCOUNT > 1) I want the task to fail. How can I do this? I have tried RAISERROR, but that does not work.

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2002-03-12 : 20:43:02
tried 1/0?

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

aleedy
Starting Member

2 Posts

Posted - 2002-03-13 : 08:42:47
1/0 doesn't work either.

Go to Top of Page

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2002-03-13 : 09:53:50
Right click on the execute sql task, select workflow properties, select the options tab, and check "fail package on step failure".

Go to Top of Page

JamesH
Posting Yak Master

149 Posts

Posted - 2002-03-13 : 11:12:26
Here's some code that I use to check for system dates that if they're not the current day then the step is forced to fail. You should be able to use the DTSStepExecResult_ (Success/Fail) and do the same.



'**********************************************************************
' Visual Basic ActiveX Script
'************************************************************************

function Main()

Dim f, fs




Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile("\\SAPSRV\files\outbound\newinfo\shipments.txt")

If FormatDateTime(f.DateLastModified, vbShortDate) = FormatDateTime(Date, vbShortDate) Then
main = DTSTaskExecResult_Success

else
main = DTSStepExecResult_Failure

End If



' MsgBox f.DateLastModified

Set f = Nothing
Set fs = Nothing


End function


Hope this helps,

JamesH.

Go to Top of Page
   

- Advertisement -