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 |
under2811
Constraint Violating Yak Guru
366 Posts |
Posted - 2014-06-04 : 07:29:29
|
Hi All,I am not much aware of scripting task. My requirement is like read csv file and collect the date value and assign it to variable. That variable I will use in next task. I want on particular row say on fourth row value assign to date variable.T.I.A |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-06-04 : 08:19:32
|
SSIS can read CSV files directly, I believe. Then you can use the date column.See the article: http://blog.sqlauthority.com/2011/05/12/sql-server-import-csv-file-into-database-table-using-ssis/ |
|
|
under2811
Constraint Violating Yak Guru
366 Posts |
Posted - 2014-06-04 : 08:33:55
|
thank you for replied.But my file format is different for first few rows it is file information which i dont want then on fourth row there is date and from 5 rows i have header and below data.i need to check fourth row which is date and for that perticular date i need to do update or insert.so currently i am taking date as hard coded and skipping first 4 rows and then doing insert or update. But this file comoes on every day so i need that date as variable and then using it i will do rest operation.hope you understand my scenario.Please let me know if needed more info.Thanks |
|
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-06-04 : 14:46:02
|
quote: Originally posted by under2811 thank you for replied.But my file format is different for first few rows it is file information which i dont want then on fourth row there is date and from 5 rows i have header and below data.i need to check fourth row which is date and for that perticular date i need to do update or insert.so currently i am taking date as hard coded and skipping first 4 rows and then doing insert or update. But this file comoes on every day so i need that date as variable and then using it i will do rest operation.hope you understand my scenario.Please let me know if needed more info.Thanks
You can add a Conditional Split task in the dataflow. Find something unique to identify the lines you want and only let those ones through.If you post a few lines of your data it will be easier to help out |
|
|
under2811
Constraint Violating Yak Guru
366 Posts |
Posted - 2014-06-05 : 05:29:48
|
Sample dataI am interested in line number 3 i.e. date and columns WAO ID and Time from CSV.Percent of Total Amount Template 6/23/2014 VVVVV SN WAO ID SIP ID XXXX Time XXXXXXXXX 123456 1234XX56 @NA 1.23456XZZZZ 789012 @NA @NA NAYYYYYY 126788 123456VV45 @NA 2.34567Hope yu get better idea.. |
|
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-06-05 : 09:41:48
|
Well, your "CSV" data is not Comma Separated Values! Also, can you show your desired results?BTW,I almost have this working in SSIS. I defined two flat-file inputs: one for the header rows and one for the data rows. I get the date from the header rows. Now, what comes next? |
|
|
|
|
|