Jump to content
Fórum Script Brasil
  • 0

Exportar resultado do SQL para Excel


BrunoKNS

Question

Boa Tarde Pessoal,

Eu pesquisei algumas possibilidades sobre export do sql para excel, consegui montar uma solução pelo wizard porém na minha maquina funciona e no servidor gera o seguinte erro:

- Executing (Error)

Messages

Warning: Preparation SQL Task 1: Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done. (SQL Server Import and Export Wizard)

Warning: Preparation SQL Task 1: Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done. (SQL Server Import and Export Wizard)

Error 0xc002f210: Preparation SQL Task 1: Executing the query "CREATE TABLE `SERVICO` (

`SERVICO` Byte,

`DESCRI..." failed with the following error: "Cannot modify the design of table 'SERVICO'. It is in a read-only database.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

(SQL Server Import and Export Wizard)

---------------------------------------------------------------------------------

Então tentei pelo Openrowset, utilizando o seguinte código:

sp_configure 'show advanced options', 1;

GO

RECONFIGURE;

GO

sp_configure 'Ad Hoc Distributed Queries', 1;

GO

RECONFIGURE;

GO

USE EPG_TECNOLOGIA

CREATE TABLE PESSOA

(

COD INT,

NOME VARCHAR (50)

)

INSERT PESSOA VALUES(11,'LUA')

INSERT PESSOA VALUES(21,'SOL')

INSERT PESSOA VALUES(31,'UNIVERSO')

SELECT * FROM PESSOA

SELECT * FROM OPENROWSET

('Microsoft.ACE.OLEDB.12.0',

'Excel 12.0 Xml;HDR=YES; Database=C:\Data\TGB01.xlsx',

'select cod, nome from [PLAN1$]')

e também é gerado o erro:

Msg 7354, Level 16, State 1, Line 16

The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" supplied invalid metadata for column "cod". The data type is not supported.

alguém consegue me ajudar a resolver pois desconheço esse erro e não encontrei nada relacionado.

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...