Wednesday, March 7, 2012

How can I import CSV or Excel data into SQL2005 Express ?

How can I import CSV or Excel data into SQL2005 Express ?
Thanks.
You can run a query using BULK INSERT to import a CSV file:
BULK INSERT MyTable
FROM 'c:\data.csv'
WITH (FIELDTERMINATOR = ',',
ROWTERMINATOR ='\n')
And one way to import Excel sheet:
INSERT INTO MyTable
SELECT *
FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',
'Data Source=C:\Test.xls;Extended Properties="Excel
8.0;IMEX=1"')...[Sheet1$];
HTH,
Plamen Ratchev
http://www.SQLStudio.com
|||I would only use this as a last resort - but depending on the spreadsheet
size , you can copy and paste via the Management Studio - assuming you have
the tables properly defined/mapped
Jack Vamvas
___________________________________
Search IT jobs from multiple sources- http://www.ITjobfeed.com
"Yips" <alvin@.yipschemical.com> wrote in message
news:OnpgVgGaIHA.4696@.TK2MSFTNGP05.phx.gbl...
> How can I import CSV or Excel data into SQL2005 Express ?
> Thanks.
>
|||It works. Thanks.
"Jack Vamvas" <DEL_TO_REPLY@.del.com> wrote in message
news:Psydnci4PfWI4zTaRVnyvwA@.bt.com...
>I would only use this as a last resort - but depending on the spreadsheet
>size , you can copy and paste via the Management Studio - assuming you have
>the tables properly defined/mapped
> --
> Jack Vamvas
> ___________________________________
> Search IT jobs from multiple sources- http://www.ITjobfeed.com
>
>
> "Yips" <alvin@.yipschemical.com> wrote in message
> news:OnpgVgGaIHA.4696@.TK2MSFTNGP05.phx.gbl...
>

No comments:

Post a Comment