
www.Usenet.com
| <-- __Chronological__ --> | <-- __Thread__ --> |
Erland, thank you so much for your help.
Will this convert the rows to a single row for each pc text file?
For example:
pc1.txt
Computer Name,
144.5.2.1,
Windows NT,
So that this becomes:
Computer Name, 144.5.2.1, Windows NT, in a sql table
Or,
Do I first have to somehow (god knows how), convert the text file into:
Computer Name, 144.5.2.1, Windows NT, in a sql table?
How does bcp know to do this?
Pardon my ignorance, and thank you so much for your help.
Simon
--
---------------------------------------------------------------------
"Are you still wasting your time with spam?...
There is a solution!"
Protected by GIANT Company's Spam Inspector
The most powerful anti-spam software available.
http://mail.spaminspector.com
"Erland Sommarskog" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Michelle Hillard ([EMAIL PROTECTED]) writes:
> > I have 120 computers to support and I have generated the following type
> > text file recording some inventory stuff for each pc.
> >
> > pc1.txt
> > Computer Name, PC01
> > IP Address, 144.5.2.1
> > Operating System, Microsoft Windows XP Home Edition 5.1.2600
> > etc etc
> >
> > pc2.txt
> > Computer Name, PC02
> > IP Address, 144.5.2.2
> > Operating System, Microsoft Windows XP Home Edition 5.1.2600
> > etc etc
> >
> > What I would like to do is:
> >
> > Import these text files into a sql table with setup like:
> >...
> > One row in a table for each computer.
> > How can you convert the rows in each text file to be a single row in a
sql
> > table?
>
> First make the table wide enough to hold also the labels.
>
> Next copy all files into one:
>
> copy pc*.txt all_pcs.txt
>
> (You may have to play around to get the exact syntax right.)
>
> Then you can use BCP from the command prompt:
>
> bcp db..tbl in all_pcs.txt -T -c -r\n -t\n
>
> Then run this:
>
> UPDATE tbl
> SET computer_name = replace('Computer Name, ', ''),
> ip_address = replace('IP Address, ', ''),
> os = replace('Operating system, ', '')
>
> Note that for the BCP to work there must not be any extra newlines
> somewhere.
>
> --
> Erland Sommarskog, SQL Server MVP, [EMAIL PROTECTED]
>
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
| <-- __Chronological__ --> | <-- __Thread__ --> |