May 13, 2008 at 9:23 am
Hi,
I am working on a project in which someone will drop up to 5 (.txt) files into a directory on a shared drive. I have to go in and pull each row from each (.txt) file and place it into a SQL table.
Any assistance would be appreciated.
Thanks
May 13, 2008 at 12:25 pm
Have you tried using DTS? This would be a pretty simple task using the text file source connection.
May 16, 2008 at 6:47 am
[font="Verdana"]Try Bulk Insert as well. Syntax:
Bulk Insert {Table Name}
From {File Name with complete path}
With {Different Hints}
For more information on Bulk Insert refer BOL and the below URL as well.
http://msdn.microsoft.com/en-us/library/ms188365.aspx
Mahesh
[/font]
MH-09-AM-8694
May 16, 2008 at 11:13 pm
jalphor (5/13/2008)
Hi,I am working on a project in which someone will drop up to 5 (.txt) files into a directory on a shared drive. I have to go in and pull each row from each (.txt) file and place it into a SQL table.
Any assistance would be appreciated.
Thanks
Jalphor,
If DTS isn't what you want, then Mahesh is correct... Bulk Insert will do... but it will need to be in the form of "dynamic" SQL to get the file name/path to change.
To read file names in a given path, consider the following (try it)....
EXEC Master.dbo.xp_DirTree 'C:\',1,1
The "File" column should be pretty much self-explanatory. You can insert the output of that extended proc into a table using INSERT/EXEC.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply