Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Force DTS Failure

Force DTS Failure

Scheduled Pinned Locked Moved Database
databasetoolshelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bjohnson33
    wrote on last edited by
    #1

    Hi all I'm trying to write a DTS that as it's first step checks a log table as to whether the process has already run for that date, and if it has, exit. I thought I'd be able to have an 'Execute SQL Task' with something like the following: DECLARE @ContributionDate DATETIME DECLARE @NoOfRecords INT SET @ContributionDate = GetDate() CREATE TABLE #Results(NoOfRecords INT) INSERT INTO #Results EXEC db.dbo.vsDissemination_HasRun @ContributionDate, 'C' SET @NoOfRecords = (SELECT TOP 1 NoOfRecords FROM #Results) DROP TABLE #Results IF @NoOfRecords > 0 BEGIN RAISERROR('Dissemination has occurred',1,1) END ELSE SELECT 1 Which when the error was raised would go down the On Failure branch, but it always goes to the On Success branch. Running the script in Query Analyzer does either return a numeric value or an error. Firstly, is this the best way to do this check? If it is, why doesn't it work - if not, how should I be doing this? Thanks Ben

    A 1 Reply Last reply
    0
    • B Bjohnson33

      Hi all I'm trying to write a DTS that as it's first step checks a log table as to whether the process has already run for that date, and if it has, exit. I thought I'd be able to have an 'Execute SQL Task' with something like the following: DECLARE @ContributionDate DATETIME DECLARE @NoOfRecords INT SET @ContributionDate = GetDate() CREATE TABLE #Results(NoOfRecords INT) INSERT INTO #Results EXEC db.dbo.vsDissemination_HasRun @ContributionDate, 'C' SET @NoOfRecords = (SELECT TOP 1 NoOfRecords FROM #Results) DROP TABLE #Results IF @NoOfRecords > 0 BEGIN RAISERROR('Dissemination has occurred',1,1) END ELSE SELECT 1 Which when the error was raised would go down the On Failure branch, but it always goes to the On Success branch. Running the script in Query Analyzer does either return a numeric value or an error. Firstly, is this the best way to do this check? If it is, why doesn't it work - if not, how should I be doing this? Thanks Ben

      A Offline
      A Offline
      andyharman
      wrote on last edited by
      #2

      Try RAISERROR('Dissemination has occurred',16,1).

      B 1 Reply Last reply
      0
      • A andyharman

        Try RAISERROR('Dissemination has occurred',16,1).

        B Offline
        B Offline
        Bjohnson33
        wrote on last edited by
        #3

        Thanks Andy - The error is now being thrown (if I run the package in the designer) but it doesn't go to the On Failure step - is that expected? Ben

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups