Getting data for current month - Urgent

  • Hello Friends,

    I am using SSIS and I have SQL Server Source and the same Destination. I have a column datetime created in my source and it contains data for about 15 years. I just want to retrieve the data for the current month. i.e, from September 1, 2008 to September 17, 2008. Can anyone plz help me, how can I achieve this?

    Using Conditional Split Transformation or SQL Query for this? I want to do this task using SSIS.

    Thank you.

    notes4we

  • You should use a Query as your source in SSIS. So your query would be something like this:

    [font="Courier New"]SELECT

       columns

    FROM

       TABLE

    WHERE

       -- all the calculation does is return midnight of the first day of the current month

       Date >= CONVERT(VARCHAR(10), DATEADD(DAY, -DAY(GETDATE()) + 1, GETDATE()), 101) AND

       Date <= GETDATE()

    [/font]

  • Hello Jack,

    I am not able to see the results because of an error in the destination.

    The error message is:

    [OLE DB Destination [312]] Error: An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "The statement has been terminated.". An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Violation of PRIMARY KEY constraint 'PK_T_Load_Forecast'. Cannot insert duplicate key in object 't_load_forecast'.".

    Can you please help me to figure out why there is this error?

  • You have at least 1 duplicate primary key value. An easy way to identify the rows that have duplicate PK's is to change the source to redirect error rows (COnfigure Error Output) and either send them to a file or another table without the PK.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply