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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Correct Script

Author  Topic 

easy_goer
Starting Member

21 Posts

Posted - 2007-02-05 : 01:22:42
Hello. I am trying to create a table from a text file that I created which contains a Windows directory structure. For instance, my text file contains lines that look something like this...

K:\10\3980-Test Level1\3908IUL0-Test Level2\Microsoft\Windows
K:\20\5892-Test Data1\3902KMKD-Test Data2\SQL\Files

I would like my table to contain the following columns. In this example my columns are separated by the pipe symbol. The levels are the same as the levels in Windows file structure above.

FULL PATH | 2ND LEVEL | 3RD LEVEL | 4TH LEVEL | 5TH LEVEL

So, anyways what my script should look like to obtain my desired table?

Thanks,
Keith

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-02-05 : 01:28:31
What do you want actually ? I am a bit confuse. You want the create table script ?

create table yourtable
(
[FULL PATH] varchar(1000),
[2ND LEVEL] varchar(1000),
[3RD LEVEL] varchar(1000),
[4TH LEVEL] varchar(1000),
[5TH LEVEL] varchar(1000),
)


Or do you want to know how to import your text file into the table ?


KH

Go to Top of Page

easy_goer
Starting Member

21 Posts

Posted - 2007-02-05 : 10:53:21
Yes, I am looking for a way to import my text file into the table. Sorry for the confusion. Thanks.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-02-05 : 17:18:38
you can use dts, bcp or bulk insert to import the text file to a single column table then split it into the various level you want.


KH

Go to Top of Page
   

- Advertisement -