Execute SQL Task does not Update from a Date Variable Reliably

I'm using a DateTime variable in SSIS 2008 that is used to set the SQLStatement property of an Execute SQL Task.
"DELETE FROM Labor WHERE Week = '" + (DT_WSTR, 100) @[User::Week] + "'"
Week is the next Sunday:
DATEADD( "day", @[User::DaysTillSunday] , @[User::TheDayThatIsTwentyMinutesPrior] )
DaysTillSunday:
DATEPART( "dw", @[User::TheDayThatIsTwentyMinutesPrior] ) == 1 ? 0 : 8 - DATEPART( "dw", @[User::TheDayThatIsTwentyMinutesPrior] )
TheDayThatIsTwentyMinutesPrior:
(DT_DATE)(DT_DBDATE)DATEADD("minute",-20,GETDATE())
The SSIS Package deletes the current week's data, reloads it with fresh data, then calculates the difference between the current week and last week.
The problem is that randomly, instead of deleting the current week, it will delete the previous week.  This happens maybe 5-10% of the time.  At least it does until I rebuild the package and import it into SQL Server again.
I'm guessing that the Execute SQL Task is not updating the value of the Week variable before it executes.  I started with the source type being a variable.  Then I decided to try Direct input and pass in the Week as a parameter (OLE DB Connection
Type).  That didn't work either.
Most recently I tried writing the Week variable to a table first, then having a sequence container with all the tasks second.  Slightly better but I still saw the date was wrong 2 times in about 90 executions.  I was hoping that writing the Week
variable out to the database would force an update of any associated connections to it, but that didn't seem to work.
Any ideas?  Is this a known issue, am I missing a setting?
thanks,
John

John, computers either work all the time or have a bug. I suspect it is the latter.
To find it [faster] you need to log what the resulting expression was used in the package.
I am baffled how rebuilding a package would fix anything like setting a date.
It might be even dependant on when you run the package.
Why
DATEADD("minute",-20,GETDATE())
DATEADD( "day", -8 , GETDATE() )
It must be enough to set the week (that appears to be a date) as above.
Arthur
MyBlog
Twitter

Similar Messages

  • My CS6 Production suite does not update from the help menu? The appilcation Manager says: "The updat

    My CS6 Production suite for Windows 8 does not update from the help menu? The appilcation Manager says: "The update server is not respondiing, the server might be offline temporarily..." I have registered correctly. I have turned off my AVG virus protection and tried to update my software, still the Application Manager gives the same response. When I login, I can see that my serial numbers are there, so it must have registered correctly.
    Help!

    If you don't want to download the updates manually, then you need to update your Application Manager.  The relevant links are here:
    Windows
    http://www.adobe.com/support/downloads/detail.jsp?ftpID=4773
    Mac
    http://www.adobe.com/support/downloads/detail.jsp?ftpID=4774
    Hope this helps.

  • When Hard-coded server name and data base name are replaced with variables , execute process task does not produce the result

    Hi All,
    I am trying to load shape file into a sql spatial table. A execution process task is used to run the ogr2ogr.exe program.
    This is how the process tab looks like .
    Executable : C:\gdal_ogr2ogr\bin\gdal\apps\ogr2ogr.exe
    Argument :  -f MSSQLSpatial   MSSQL:server=SQL-ABC-DEV;database=MYSIMPLE_Dev;Trusted_Connection=True;\\mypath\files\shares\Data\www.mypage.htm\my_sample_file.shp
    Success value : 1
    For above settings, package runs fine. The spatial table is created in SQL server db. However when hard-coded SQL server name and database name are replaced with global variables , the spatial table is not created in the database. Yet the package runs fine.
    It does not throw any errors. (I am using another variable for full file path. It is not causing any errors though)
    " -f MSSQLSpatial   MSSQL:server="+@[$Project::SQLServerName]+";database="+ @[$Project::DatabaseName] +";Trusted_Connection=True;"+ @[User::Filepath] + "\\my_sample_file.shp"
    Both variables are string type. Can anyone tell me what I am doing wrong here please?
    I am running this in VS 2012.
    Thanks for your help in advance..
    shamen

    There should be a single space just after True:
    before
    " -f MSSQLSpatial   MSSQL:server="+@[$Project::SQLServerName]+";database="+ @[$Project::DatabaseName] +";Trusted_Connection=True;"+ @[User::Filepath] + "\\my_sample_file.shp"
    after keeping the space
    " -f MSSQLSpatial   MSSQL:server="+@[$Project::SQLServerName]+";database="+ @[$Project::DatabaseName] +";Trusted_Connection=True; "+ @[User::Filepath] + "\\my_sample_file.shp"
    Thanks
    shamen

  • Updating task does not update project plan

    In PWA, the following steps are taken
    User updates their time in the task window for a task, than submits this task
    The PM approves the time entry from approval center
    The PM then opens the project from PWA or Project pro and the time that approved for this task is not showing up in the project plan
    This happens in all projects
    Project server is not configured with SEM
    At queue jobs, Job state is "Skipped For Optimization" for status update jobs
    Why is the project not recognizing the time entry?
    Thank you.
    Sincerely, Murad YAGLI, MBA PMP MCT MCPD:EAD MCITP MCSD .NET MCDBA MCAD, www.murady.com

    I am running into this same issue with PWA 2013.  I publish a task, have the resource update it via my tasks in PWA, then Open Pro and Check Progress.  Pro redirects me to the Approvals page in PWA.  I approve the task update, Pro pops several
    message windows asking me to wait while the update is processed.  The update processiong finishes and...
    No progress indicated.  No actual work indicated.  I have tried opening the Working vs. Published version of the schedule.  No difference.  It appears to be something specific to this project schedule, as other schedules work just fine. 
    I have multiple resource assignments on the task in question.  I've checked the assignmnet dates, updated task progress in PWA using various methods including work earlier than planned, as planned, work less than planned, anything to get Pro to reflect
    the update.  Pro rcognizes that there IS an update, indicated in the File / Backstag (Updates pending indicator) but it will not process them. 
    Personally I think the assignment level date in the DB is not being handled when accessed by PRO.  All the data is right if you look in PWA. 

  • My ipod does not update from version 4.1.2 to 5.0 as I do? mine ipod is 3g

    because my ipod third generation did not upgrade from 4.2 to 5.0? says that version 4.2 is the most updated!

    I suspect you really have a 2G iPod. Those can only go to iOS 4.2.1  If yours is an 8 or 16 GB one it is a 2G since Apple only made 32 and 64 GB 3G iPod.  A 32 GB one can be either.  To identify yours:
    Identifying iPod models
    Enter SN here:
    Apple - Support - Check Your Service and Support Coverage

  • LT movie viewer does not update from consecutive renders

    Working on a project I created an intro with LT using some of the Live Fonts. I did a "Render Movie..." to see the results. Noticed I had a spelling error so I went back and changed the typo, saved, and then did "Render Movie.." again. When it displayed the results the original movie with the typo played back.
    Suspecting some type of cache issue, I opened up Quicktime and selected the rendered movie and sure enough, the change had actually been made correctly, it is just that the viewer in Live Type, I suspect, is not picking up the change and playing a cached version of the first edit.
    Is there something I'm missing in a preferences setup or is this yet another "Feature" of which us users would call a bug?

    - The iPad 1 can only go to iOS 5.1.1
    For video problem try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Reset all settings
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                 
    iOS: How to back up           
    - Restore to factory settings/new iOS device.

  • SSIS File System Task does not allow entering the destination variable

    In SSIS for SQL Server 2012 (2014) I am not able to change the destination to a variable in the File System Task.  
    I have 2 variables for the source and destination path.  I pull in a File System Task, change the source to a variable, but when I select the destination I cannot enter the destination variable.  When I change destination to a variable
    the dialog disappears when I try to select the variable. 
    http://www.screenr.com/fQKN

    Hi Steve,
    I have tried myself, it is working fine. Its look like something wrong with your visual studio. try to reinstall it or reset the visual studio.(http://msdn.microsoft.com/en-us/library/ms247075(v=vs.100).aspx).
    If you really want to set destination values, you can set them from properties window of the task.(Right click the task and select properties or select the task and press f4).
    There are properties like:
    IsDestinationPathVariable (True/False)
    Destination (VariableName eg: user::target)
    Regards Harsh

  • Execute sql task not firing trigger.

    Hi Everyone,
    I am using insert and update quires in Execute SQL task i have a trigger at that table which will capture any changes. 
    When some changes are been made in management studio or front end portal the trigger is capturing but when changes are been made by the package through execute sql task it not capturing it. 
    Help would be greatly appericate it.
    Thanking You,
    Zoheb Syed.

    Hi,
    Really appericate your reply.
    Can i ask one more question hor to use FIRE_TRIGGERS command for this query in execute sql task.
    I have a trigger made in the table by name "trg_iud_Provider".
    update dbo.Provider
    set        IDX_DN3_ID=D.ID_3,
               FirstName=D.Lawson_Provider_First_Name,
               LastName=D.Lawson_Provider_Last_Name,
               FullName=D.PROVIDER_NAME,
               Specialty=D.PSA_SPECIALTY,
               Gender=D.Lawson_Gender,
               LawsonEmailAddress=D.Lawson_E_Mail,
               NPI_Number=D.NPI_NUMBER,
               StateLicenseNumber=D.STATE_LICENSE_NUMBER,
               provider_number=d.provider_number,
               DepartName=d.DepartName,
               App_User='System',
               SysEffectiveDate=GETDATE()
    from  dbo.Provider A JOIN (select  rid.ID_3,
                  rid.EMPLOYEE_NUMBER,
                  rLD.Lawson_Provider_First_Name,
                  RLD.Lawson_Provider_Last_Name,
                  RID.PROVIDER_NAME,
                  RID.PSA_SPECIALTY,
                  RLD.Lawson_Gender,
                  RLD.Lawson_E_Mail,
                  RID.NPI_NUMBER,
                  RID.STATE_LICENSE_NUMBER,
                  rid.provider_number,
                  rld.DepartName
          from dbo.raw_IDX_Feed RID FULL OUTER JOIN dbo.raw_LawsonFeed RLD
          ON RID.EMPLOYEE_NUMBER=RLD.Lawson_Employee_Number) D ON A.IDX_DN3_ID=D.ID_3
          join ProviderContract pc on pc.ProviderID=a.ProviderID
          WHERE (isnull(A.IDX_DN3_ID,9999)<>isnull(cast(D.ID_3 as int),9999)
              OR isnull(A.FirstName,'xxxx')<>isnull(D.Lawson_Provider_First_Name,'xxxx')
              OR isnull(A.LastName,'xxxx')<>isnull(D.Lawson_Provider_Last_Name,'xxxx')
              OR isnull(A.FullName,'xxxx')<>isnull(D.PROVIDER_NAME,'xxxx')
              OR isnull(A.Specialty,'xxxx')<>isnull(D.PSA_SPECIALTY,'xxxx')
              OR isnull(A.Gender,'x')<>isnull(D.Lawson_Gender,'x')
              OR isnull(A.LawsonEmailAddress,'xxxx')<>isnull(D.Lawson_E_Mail,'xxxx')
              OR isnull(A.NPI_Number,'99999')<>isnull(D.NPI_NUMBER,'99999')
              OR isnull(A.StateLicenseNumber,'xxxx')<>isnull(D.STATE_LICENSE_NUMBER,'xxxx')
              or isnull(a.provider_number,'99999')<>isnull(d.provider_number,'99999'))
              and pc.LawsonTermdate is null
              and pc.FinanceTermdate is null 

  • Office 2013 C2R Update Scheduled Task does not work

    Hi all.
    I am having difficulty getting network deployed updates to work correctly. I installed and older version of Office 2013 with the ODT from a network share and set the update path. I then downloaded an update via ODT.
    The issue is the scheduled task does not update office. If I trigger or manually run from a command prompt "C:\Program Files\Microsoft Office 15\ClientX64\integratedoffice.exe RUNMODE RERUNMODE modetorun updatedetection modeargs reschedulemode tasktrigger
    scheduledtask updateuitype background” from Task Scheduler nothing seems to happen. Monitoring Task Manager it looks like integratedoffice is called albeit very briefly.
    But, if I run "C:\Program Files\Microsoft Office 15\ClientX64\integratedoffice.exe RUNMODE RERUNMODE modetorun updatedetection background” from a command prompt Office updates, but if I edit the Scheduled Task to above Office does not update if the
    task is triggered.
    As Office can update if the right command is given it would appear that my config.xml etc is correct. Any ideas on why the Scheduled Task does not work?
    Cheers
    Jakes

    What permissions are set on the location of the updates ? C2R currently needs permissions granted for machine accounts as it runs under that context. This will change at some point that C2R gets updated.

  • Failed to create an IDataAdapter object. This provider may not be fully supported with the Execute SQL Task

    I executed a simple query inside an execute SQL task - 
    SELECT col1, col2
    from thetable
    where code = ?
    order by id asc
    Exec sql task - ADO.NET connection
    parameter "code" is an int32 in SSIS and int32 in parameter mapping of exec sql task.
    It works fine in SQL server, but in SSIS it causes the error - 
    [Execute SQL Task] Error: Executing the query "SELECT col1, col2
    from thet..." failed with the following error: "Failed to create an IDataAdapter object. This provider may not be fully supported with the Execute SQL Task. Error message 'Incorrect syntax near '?'.'.". Possible failure reasons: Problems with
    the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
    How do I fix this error ? 

    Thanks. I think it was sqlclient. I changed it to OLEDB to avoid that issue. Btw, what is this "provider" ?
    Hi blastoSO,
    To check which provider is used by the current ADO.NET Connection Manager, you can open the “Configure ADO.NET Connection Manager” window, and check the “Managed Provider” option of each Data connection.
    In an Execute SQL Task, if the managed provider is “System.Data.SqlClient”, we should use the rule for the ADO.NET connection type in the following table. If the managed provider is “System.Data.Oledb” or “System.Data.Odbc”, it actually uses the OLE DB provider
    or ODBC provider, so we should use the rule for the OLE DB or OBC rule in the following table:
    Reference:
    http://technet.microsoft.com/en-us/library/cc280502.aspx
    Regards,
    Mike Yin
    TechNet Community Support

  • Why is my Package just stopping when going from one Execute SQL Task to another Execute SQL Task

    I have one flow constraint going for my one Execute SQL Task to another Execute SQL Task. It's executing #1 and successfully and just stops there rather than continuing on to Execute SQL Task #2. Why would it just stop? My constraint is NOT conditional...just
    a straight ole flow constraint.
    Any help is greatly appreciated and Thanks in Advance for your help.
    PSULionRP

    Hi PSULionRP,
    First make sure the color of the Precedence Constraint is green (Success) or blue (Completion) other than red (Failure). Then, make sure the Execute SQL Task is not disabled (right click the executable, and “Disable” option is available in the right-click
    menu). 
    Regards,
    Mike Yin
    TechNet Community Support

  • HELP: SSIS 2012 - Execute SQL Task with resultset to populate user variables produces DBNull error

    I am experiencing an unexplainable behavior with the Execute SQL Task control in SSIS 2012. The following is a description of how to simulate
    the issue I will attempt to describe:
    1. Create a package and add two variables User::varTest1 and User::varTest2 both of String type with default value of "Select GetDate()"
    for each, have shown this to not matter as the same behavior occurs when using a fixed string value or empty string value.
    2. Add a new Execute SQL Task to the control flow.
    3. Configure an OLE DB connection.
    4. Set SQLSourceType = "Direct Input"
    5. Set the ResultSet property of the task to "Single Row"
    6. In the ResultSet tab add two results as follows: 
    Result Name: returnvalue1, Variable Name: User::varTest1
    Result Name: returnvalue2, Variable Name: User::varTest2
    7. Set an expression for the SqlStatementSource property with a string value of "Select 'Test' returnvalue1, 'Testing' returnvalue2'"
    The idea is that the source would be dynamically set in order to run a t-sql statement which would have dynamic values for database name
    or object that would be created at runtime and then executed to set the user variable values from its resultset. Instead what occurs is that a DBNull error occurs.
    I am not sure if anyone else has experienced this behavior performing similiar actions with the Execute SQL Task or not. Any help would be
    appreciated. The exact message is as follows:
    [Execute SQL Task] Error: An error occurred while assigning a value to variable "varRestoreScript": "The type of the value
    (DBNull) being assigned to variable "User::varRestoreScript" differs from the current variable type (String). Variables may not change type during execution. Variable types are strict, except for variables of type Object.
    User::varRestoreScript is the first return value. And even with the a dummy select the same result occurs. I have narrowed the issue down
    to the T-SQL Statement structure itself. 
    The following works just fine within the execute sql task control as long as no resultset is configured for return:
    "Declare @dynamicSQL nvarchar(max)
    Select @dynamicSQL = name 
    From sys.databases 
    Where name = 'master'
    Select atest_var1=@dynamicSQL, atest_var2='static'"
    I have tried various iterations of the script above with no success. However, if I use the following derivative of it the task completes
    successfully and variables are set as expected.  This will not work for my scenario however as I need to dynamically build a string spanning multiple resultsets to build one of the variable values.
    "Select atest_var1=name, atest_var2='static'
    From sys.databases
    Where name = 'master'
    I have a sample package which can reproduce this issue using the above code.  You can get to that through the post on www.sqlservercentral.com/Forums/Topic1582670-364-1.aspx
    Scott

    Arthur,  the query when executed doesn't return a null value for the @dynamicSQL variable.  It returns "master" as a string value.  Even the following fails which implements that suggestion:
    Declare @dynamicSQL as nvarchar(max)
    Select @dynamicSQL = name
    From master.sys.databases 
    Where name = 'master' -- (or any other DB name)
    I believe I have found the cause of the issue.  It is datatype and size related.  The above script will properly set the variables in the resultset as long as you don't use nvarchar(max) or varchar(max).  This makes the maximum data size for
    a String variable 4000 characters whether unicode or non-unicode typed.

  • How do I return two values from a stored procedure into an "Execute SQL Task" within SQL Server 2008 R2

    Hi,
    How do I return two values from a
    stored procedure into an "Execute SQL Task" please? Each of these two values need to be populated into an SSIS variable for later processing, e.g. StartDate and EndDate.
    Thinking about stored procedure output parameters for example. Is there anything special I need to bear in mind to ensure that the SSIS variables are populated with the updated stored procedure output parameter values?
    Something like ?
    CREATE PROCEDURE [etl].[ConvertPeriodToStartAndEndDate]
    @intPeriod INT,
    @strPeriod_Length NVARCHAR(1),
    @dtStart NVARCHAR(8) OUTPUT,
    @dtEnd NVARCHAR(8) OUTPUT
    AS
    then within the SSIS component; -
    Kind Regards,
    Kieran. 
    Kieran Patrick Wood http://www.innovativebusinessintelligence.com http://uk.linkedin.com/in/kieranpatrickwood http://kieranwood.wordpress.com/

    Below execute statement should work along the parameter mapping which you have provided. Also try specifying the parameter size property as default.
    Exec [etl].[ConvertPeriodToStartAndEndDate] ?,?,? output, ? output
    Add a script task to check ssis variables values using,
    Msgbox(Dts.Variables("User::strExtractStartDate").Value)
    Do not forget to add the property "readOnlyVariables" as strExtractStartDate variable to check for only one variable.
    Regards, RSingh

  • Execute SQL Task - UPDATE or Data Flow Data Conversion

    Good Morning folks,
    I want to know which is more fast to convert data type.
    I want to convert nvarchar(255) to datetime2,
    using t-sql (execute sql task)
    UPDATE TBL
    SET  FIELD1= CAST(FIELD1AS DATETIME2)
    GO
    or data conversion(data flow)
    Thank..

    Itz Shailesh, my t-sql have only UPDATE, not many UPDATES... so it's one batch, no 2,3,4... So.. it's Only one update.. ex: update table set field1 = cast(field1 as datetime2), field2 = cast(field2 as datetime2). not : update table set field = cast(field
    as datetime2) go    update table set field2 = cast(field2 as datetime2) go.... understand?
    Yeah, I understand that you have to update just 1 field. What I am saying, if you have to update millions of rows then you must update rows in batches ( lets say batch of 50k). This way you will only touch 50k rows at a time and not all rows from table.
    I see that your rows are less however I would still prefer the option of data conversion transformation over update statement.
    If this post answers your query, please click "Mark As Answer" or "Vote as Helpful".

  • Execute SQL Task with Parameter - from DB2 to SQL Server

    I am pulling data from DB2 to SQL Server.
    1st Execute SQL task runs the following against DB2:
    SELECT TIMESTAMP(CHAR(CURRENT_DATE - (DAY(CURRENT_DATE)-1) DAYS - 1 MONTH)) as START_MONTH
    FROM SYSIBM.SYSDUMMY1;
    I'm storing it as a Result Set.
    Next I have a Data Flow Task.  This pulls data from DB2 where the date matches the parameter.
    FROM SCHEMA.TABLE t
    WHERE DATE_TIME_COLUMN= ?
    This works fine. Guessing, because the parameter source is DB2 and the Data Flow source is DB2.
    The problem is, I want to remove existing data for the same date in the SQL table.  IE, if I'm pulling March 2014 data from DB2, I want to be sure there is no March 2014 data in the SQL table.  The main use is for re-runs.
    So, I added another Execute SQL task after the first one that assigns the variable, and before the Data Flow Task. This runs the following statement against SQL Server:
    DELETE FROM
    database.dbo.table
    WHERE DATE_TIME_FIELD >= ?
    The package fails at the new Execute SQL Task with the following error message:
    Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query "DELETE FROM
    SBO.dbo.tblHE_MSP_FEE_BUCKETS
    WHERE T..." failed with the following error: "Parameter name is unrecognized.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established
    correctly.
    Task failed: Execute SQL Task
    SSIS package "Load_MSP_Fee_Buckets_SQL.dtsx" finished: Success.
    The program '[14240] Load_MSP_Fee_Buckets_SQL.dtsx: DTS' has exited with code 0 (0x0).
    I am assuming this is something to do with the Parameter source being DB2, and trying to use against SQL?
    Any suggestions on how to make this work??
    Thanks,
    -Al H

    Parameter name is unrecognized
    is the key, how come DB2 is related if it runs against SQL Server
    What I think is happening you do not use the OLEDB connection to SQL Server.
    Likewise, if it is ADO then the query needs to be
    DELETE FROM
    database.dbo.table
    WHERE DATE_TIME_FIELD >= @MyDate
    Arthur My Blog

Maybe you are looking for

  • Error while posting PR to an internal order

    Hi, We are getting the error as "ME 299 Error in commitments check" while creating PR against an Internal order. We have analyzed the issue from the budget perspective for IO and found that there is adequate amount (in K023 ) for the order. The error

  • BPM Collect

    Hi Gurus, I've got the following scenario:  I need to collect messages of the following structure <ID>1234567     <ITEM>A</<ITEM>   </ID> <ID>1234567    <ITEM>B</ITEM>   </ID>   <ID>1234567     <ITEM>C</ITEM>   </ID> and map it to the structure <ID>1

  • How to craete Source system in BW from R/3 box

    Hi, I requested to basis to create source system in bw with R/3 Box.they were created RFC connection and told me to create source system in the BW . Iam not sure how to create. please can any body help me in creating source system in BW with R/3 syst

  • Test data for mb01

    Hi, Can we get some test data for posting GR in mb01?If yes, where can we get the data? I am on a 4.7 ides system. Regards, CA

  • XML parsers with JDK1.5

    Does anyone know if the xml parsers that are shipped with JDK1.5 conform to DOM level2 or DOM level3 specification? I am not sure how to locate the parser that is shipped with the JDK either!