Friday, March 30, 2012

load csv into SQL Server 2005

I have been pulling my hair out all afternoon trying to figure out an easy
way to import csv files into SQL Server 2005. They are perfmon logs in csv
format with TONS of columns, so creating the table and columns beforehand is
not practical. Isn't there some very easy, straightfoward way to simply
create a table and its columns based up on a csv file import?
thanks in advance,
BillIn SQL Server Managemetn Studio, right click on the database name and
choose Tasks... Import Data. This opens the Import Export Wizard.
Specify a Flat File data source. Give it your .csv file name. If
your csv file has column names in the first line, check that box. Use
Preview to see how it looks, and make whatever adjustments it takes to
make it look right. Keep following the steps, and you should end up
with a new table in your database. It will probably not be exactly
what you want!!! Data types will be a bit screwy, names will probably
not be formatted correctly.
Now script that table so you have a CREATE TABLE command. Edit it
until the names and types are right and make the new table. Then
repeat the process above, but this time in the panel labelled Select
Source and Table Views change the Desitnation to the new table you
created. Take through the rest of the steps and the data should load.
I have simplified things a bit - there are far too many details to go
into here - but the approach should get you where you want to go.
Good luck!
Roy Harvey
Beacon Falls, CT
On Tue, 2 May 2006 16:49:10 -0400, "bu" <bu@.nospam.com> wrote:
>I have been pulling my hair out all afternoon trying to figure out an easy
>way to import csv files into SQL Server 2005. They are perfmon logs in csv
>format with TONS of columns, so creating the table and columns beforehand is
>not practical. Isn't there some very easy, straightfoward way to simply
>create a table and its columns based up on a csv file import?
>thanks in advance,
>Bill
>|||Take a look at the Windows utility relog.exe
Linchi
"bu" wrote:
> I have been pulling my hair out all afternoon trying to figure out an easy
> way to import csv files into SQL Server 2005. They are perfmon logs in csv
> format with TONS of columns, so creating the table and columns beforehand is
> not practical. Isn't there some very easy, straightfoward way to simply
> create a table and its columns based up on a csv file import?
> thanks in advance,
> Bill
>
>|||Do you know if that same procedure applies in SQL Server 2005 Express as
well as Standard and the others?
thanks again!
Bill
"Roy Harvey" <roy_harvey@.snet.net> wrote in message
news:06jf529da1ocliljc48nhkihkli7mm5j99@.4ax.com...
> In SQL Server Managemetn Studio, right click on the database name and
> choose Tasks... Import Data. This opens the Import Export Wizard.
> Specify a Flat File data source. Give it your .csv file name. If
> your csv file has column names in the first line, check that box. Use
> Preview to see how it looks, and make whatever adjustments it takes to
> make it look right. Keep following the steps, and you should end up
> with a new table in your database. It will probably not be exactly
> what you want!!! Data types will be a bit screwy, names will probably
> not be formatted correctly.
> Now script that table so you have a CREATE TABLE command. Edit it
> until the names and types are right and make the new table. Then
> repeat the process above, but this time in the panel labelled Select
> Source and Table Views change the Desitnation to the new table you
> created. Take through the rest of the steps and the data should load.
> I have simplified things a bit - there are far too many details to go
> into here - but the approach should get you where you want to go.
> Good luck!
> Roy Harvey
> Beacon Falls, CT
>
> On Tue, 2 May 2006 16:49:10 -0400, "bu" <bu@.nospam.com> wrote:
> >I have been pulling my hair out all afternoon trying to figure out an
easy
> >way to import csv files into SQL Server 2005. They are perfmon logs in
csv
> >format with TONS of columns, so creating the table and columns beforehand
is
> >not practical. Isn't there some very easy, straightfoward way to simply
> >create a table and its columns based up on a csv file import?
> >
> >thanks in advance,
> >Bill
> >|||I do not believe it applies to Express, as I do not think Express
comes with SSIS. SSIS is what the Wizard builds.
Roy
On Tue, 2 May 2006 21:26:51 -0400, "me" <me@.nospam.com> wrote:
>Do you know if that same procedure applies in SQL Server 2005 Express as
>well as Standard and the others?
>thanks again!
>Bill
>
>"Roy Harvey" <roy_harvey@.snet.net> wrote in message
>news:06jf529da1ocliljc48nhkihkli7mm5j99@.4ax.com...
>> In SQL Server Managemetn Studio, right click on the database name and
>> choose Tasks... Import Data. This opens the Import Export Wizard.
>> Specify a Flat File data source. Give it your .csv file name. If
>> your csv file has column names in the first line, check that box. Use
>> Preview to see how it looks, and make whatever adjustments it takes to
>> make it look right. Keep following the steps, and you should end up
>> with a new table in your database. It will probably not be exactly
>> what you want!!! Data types will be a bit screwy, names will probably
>> not be formatted correctly.
>> Now script that table so you have a CREATE TABLE command. Edit it
>> until the names and types are right and make the new table. Then
>> repeat the process above, but this time in the panel labelled Select
>> Source and Table Views change the Desitnation to the new table you
>> created. Take through the rest of the steps and the data should load.
>> I have simplified things a bit - there are far too many details to go
>> into here - but the approach should get you where you want to go.
>> Good luck!
>> Roy Harvey
>> Beacon Falls, CT
>>
>> On Tue, 2 May 2006 16:49:10 -0400, "bu" <bu@.nospam.com> wrote:
>> >I have been pulling my hair out all afternoon trying to figure out an
>easy
>> >way to import csv files into SQL Server 2005. They are perfmon logs in
>csv
>> >format with TONS of columns, so creating the table and columns beforehand
>is
>> >not practical. Isn't there some very easy, straightfoward way to simply
>> >create a table and its columns based up on a csv file import?
>> >
>> >thanks in advance,
>> >Bill
>> >
>

No comments:

Post a Comment