Introduction
This tip is continuation with my article posted here. In this article i will demonstrate to use SQL query to create initial OLEDB source, Instead of direct table access.
Using the code
Please have look on article mentioned in the Point of Interest section, this will certainly going to help you. Now if you select direct table in SSIS project, you code like this :-
srcDesignTime.SetComponentProperty("AccessMode", 0);
srcDesignTime.SetComponentProperty("OpenRowset", "[dbo].[SourceTable]");
Now for changing code for inclusion of the SQL query
string formatSQL = "SELECT * from [dbo].[SourceTable] where [Age] < 31";
srcDesignTime.SetComponentProperty("AccessMode", 2);
srcDesignTime.SetComponentProperty("OpenRowset", "[dbo].[SourceTable]");
srcDesignTime.SetComponentProperty("SqlCommand", formatSQL);
Here we have done these changes
AccessMode
is changed from 0 to 2, i.e. to accommodate the SQL Command- New property "
sqlcommand
" added , which will get actual SQL query,
Once coded you can check same in the OLEDB source connection here
Points of Interest
Have a look at the other article of series
History
Check out more article in this series!
He used to have biography here
, but now he will hire someone (for free offcourse
), Who writes his biography on his behalf
He is Great Fan of Mr.
Johan Rosengren (his idol),
Lim Bio Liong,
Nishant S and
DavidCrow and Believes that, he will EXCEL in his life by following there steps!!!
He started with Visual C++ then moved to C# then he become language agnostic, you give him task,tell him the language or platform, he we start immediately, if he knows the language otherwise he quickly learn it and start contributing productively
Last but not the least, For good 8 years he was Visual CPP MSMVP!