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.
Author |
Topic |
notes4we
Yak Posting Veteran
90 Posts |
Posted - 2008-09-17 : 11:05:16
|
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 |
|
vamsimahi
Starting Member
29 Posts |
Posted - 2008-09-17 : 11:19:42
|
For your OLEDB destination, instead of taking the data access mode as Table , take the mode as SQL command.write appropriate SQL query which compares with the source data and get the data for this month.insert this data into your other table where you want the data for just this month. |
|
|
vamsimahi
Starting Member
29 Posts |
Posted - 2008-09-17 : 12:15:56
|
If you just want to get the data for this month from those 15years data into a table, without any transformations. You can just take a Execute SQL task and write your query:insert into TABLE2select * from TABLE1where datepart(month,getdate()) = datepart(month,YourTable1Col)and datepart(year,getdate()) = datepart(year,YourTable1Col) |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-17 : 12:50:02
|
quote: Originally posted by notes4we 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
just use a execute sql task with statement asINSERT INTO DestTableSELECT * FROM SourceTableWHERE DATEADD(mm,DATEDIFF(mm,0,Yourdatecolumn),0)=DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0) |
|
|
notes4we
Yak Posting Veteran
90 Posts |
Posted - 2008-09-18 : 11:06:44
|
Thank you so much for all your replies. The business logic was that there are two units associated with a single machine. So, the number fields were units that I wanted together in one.If there are two columns UnitID1 and UnitID2, both having integers in it and if we wish to get the UnitID1 and UnitID2 as “UnitID1, UnitID2” in our destination Stations, then we use the following derived column expression. UnitID1 has no null values, but UnitID2 might have null values also.[Copy of UnitID1] + (ISNULL([Copy of UnitID2]) ? " " : " , " + [Copy of UnitID2])'Copy' as I have used Data Conversion transformation to change the datatypes before using derived column. Thank you once again all of you. |
|
|
|
|
|
|
|