Get Filename and import fixed width file
-
I just not wanting to recreate the wheel here. I need to do the following: 1.Get two parts of the filename to use wihtin the sql. The filename look like this some name here.123456.1.txt I need the 1 and the 123456 to populate two columns within the database table along with the data from the text file. the text file is fixed width 1-9 is the first column 10-18 the second column etc. I have around five hundred of these txt files I will need to loop through an process. has anyone done anything like this is a stored proc not using ssis? many thanks
-
I just not wanting to recreate the wheel here. I need to do the following: 1.Get two parts of the filename to use wihtin the sql. The filename look like this some name here.123456.1.txt I need the 1 and the 123456 to populate two columns within the database table along with the data from the text file. the text file is fixed width 1-9 is the first column 10-18 the second column etc. I have around five hundred of these txt files I will need to loop through an process. has anyone done anything like this is a stored proc not using ssis? many thanks
Open up a console-window ([Windows Key]-[R], type cmd, press enter) and execute below command;
dir "C:\Windows\m*.log" /b >files.txt
Replace my Windows location (and the wildcard) with one that's more appropriate for you. Next step is easy, you copy and paste it into MS Access. You now have a table with filenames. You could loop those in Access, and fetch the correct file and save it with some VBA-code. Then make a linked server (in Sql Server) to the Access database (one for generic imports like these) and simply copy the (appropriate) records over.
Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]
-
Open up a console-window ([Windows Key]-[R], type cmd, press enter) and execute below command;
dir "C:\Windows\m*.log" /b >files.txt
Replace my Windows location (and the wildcard) with one that's more appropriate for you. Next step is easy, you copy and paste it into MS Access. You now have a table with filenames. You could loop those in Access, and fetch the correct file and save it with some VBA-code. Then make a linked server (in Sql Server) to the Access database (one for generic imports like these) and simply copy the (appropriate) records over.
Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]
Thank you for your reply. I need to be able to do all of thee above wihtin a stored proc without depending on any other app or tool. any thoughts? again thank you for your reply.
-
Thank you for your reply. I need to be able to do all of thee above wihtin a stored proc without depending on any other app or tool. any thoughts? again thank you for your reply.