473,405 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Get files in different folder using sql

Hi All,

I have a multiple files, but they are store in different directory on
the server. I want open those files and insert it into the database
using bcp.

Example files structure dir:
\\xyz\123\abc\text1.txt
\\xyz\123\abc\text2.txt
\\zyz\123\999\text2.txt

bcp "dabase" in \\xyz\123\abc\text1.txt -c -S"servername' -Usa
-Ppassword -T".

is there away to loop througth each dir, get the files, excecute the
bcp, then go to next folder.

Please help. Thanks in advance.

Ted Lee

Aug 9 '06 #1
2 1837
I get it. Never mind.
nt******@yahoo.com wrote:
Hi All,

I have a multiple files, but they are store in different directory on
the server. I want open those files and insert it into the database
using bcp.

Example files structure dir:
\\xyz\123\abc\text1.txt
\\xyz\123\abc\text2.txt
\\zyz\123\999\text2.txt

bcp "dabase" in \\xyz\123\abc\text1.txt -c -S"servername' -Usa
-Ppassword -T".

is there away to loop througth each dir, get the files, excecute the
bcp, then go to next folder.

Please help. Thanks in advance.

Ted Lee
Aug 9 '06 #2
(nt******@yahoo.com) writes:
I have a multiple files, but they are store in different directory on
the server. I want open those files and insert it into the database
using bcp.

Example files structure dir:
\\xyz\123\abc\text1.txt
\\xyz\123\abc\text2.txt
\\zyz\123\999\text2.txt

bcp "dabase" in \\xyz\123\abc\text1.txt -c -S"servername' -Usa
-Ppassword -T".

is there away to loop througth each dir, get the files, excecute the
bcp, then go to next folder.
You could do

INSERT #tmp(files)
EXEC master..xp_cmdshell 'DIR /B \\xyz\123\abc\*.tmp'

Then run a cursor of #tmp.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Aug 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Xarky | last post by:
Hi, I have an application that makes up of files(reading data). Files are currently located on drive C. Now I am going to write the program and the files being used to a CD. The program is...
2
by: Glen | last post by:
As I understand it, when the first page of an application is accessed, all ASPX/ASCX/etc. files in the same folder are compiled using the JIT compiler. Is there a way to turn this feature off? ...
4
by: Jerry | last post by:
I'm having just a bit of trouble wrapping my brain around the task of working with folders that are above the site's root folder. I let users upload photos (.jpg/.gif files) which can...
0
by: Kleanthis | last post by:
I have a problem, when deploying multilingual applications using cab files on Compact Framework 2.0. It seems that something is going wrong with compact framework 2.0 Below I have a description...
4
by: Shiraz | last post by:
Hi I'm using Visual Studio Installer to make my installer, and have not as yet figured out a straightforward way to use it to set environmental variables. Amongst the various things I tried, I'm...
7
by: jonathandrott | last post by:
sorry newbie question probably. i'm trying to open an specific folder. open each file with in the folder individually and process each one. all the processing code has been written. i'm looking...
2
by: MichiMichi | last post by:
My asp.net application has a directory which is filled up with over 17 files (email) a second. After a while this sums up into a huge amount of files. I usually count files with the GETFILES...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
18
jhardman
by: jhardman | last post by:
Have you ever wanted to upload files through a form and thought, "I'd really like to use ASP, it surely has that capability, but the tutorial I used to learn ASP didn't mention how to do this."? ...
1
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
Using .NET 2.0 is it more efficient to copy files to a single folder versus spreading them across multiple folders. For instance if we have 100,000 files to be copied, Do we copy all of them to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.