martes, 27 de julio de 2010

MS SQL 2005: importar datos de una hoja excel a una bbdd

Microsoft explica en esta página varios métodos para hacerlo. El que yo he seguido y me ha funcionado a la primera ha sido el siguiente:

Utilizar un servidor vinculado

Después de haber vinculado un servidor ya podemos hacer una consulta del tipo:

SELECT * FROM nombreAsignado...[nombreHoja$]

2 comentarios:

  1. Luego puede haber problemas de intercalación si queremos cruzar tablas de esta base de datos con otras.

    En este caso lo aconsejable es usar:

    "nombre de columna" collate Modern_SPANISH_CI_As

    (Sustituir por el nombre de colación que corresponda)

    ResponderEliminar
  2. In SQL Server Management Studio, expand Server Objects in Object Explorer.
    Right-click Linked Servers, and then click New linked server.
    In the left pane, select the General page, and then follow these steps:
    In the first text box, type any name for the linked server.
    Select the Other data source option.
    In the Provider list, click Microsoft Jet 4.0 OLE DB Provider.
    In the Product name box, type Excel for the name of the OLE DB data source.
    In the Data source box, type the full path and file name of the Excel file.
    In the Provider string box, type Excel 8.0 for an Excel 2002, Excel 2000, or Excel 97 workbook.
    Click OK to create the new linked server.

    ResponderEliminar