Is this somehow possible?

execute immediate ('read c:\\temp\\myScript.sql');

asked 02 Jun, 07:54

Baron's gravatar image

accept rate: 48%

No, READ is a DBISQL command (like INPUT and OUTPUT) whereas EXECUTE IMMEDIATE is executed in the database engine. It's the same reason why stored procedures cannot contain OUTPUT commands.

What exactly are you trying to achieve?

Note, you can use PARAMETERS within DBISQL scripts and therefore parametrize the statements within command files, if that's what you up to.

And of course, within your SQL code, you can build command lines for DBISQL and any script files and then use xp_cmdshell to run them...

permanent link

answered 02 Jun, 08:08

Volker%20Barth's gravatar image

Volker Barth
accept rate: 34%

edited 02 Jun, 08:14


You could use xp_read_file to supply the content to execute immediate. For example;

execute immediate(xp_read_file( 'c:\temp\myScript.sql' ))

This assumes that the myScript.sql is accessible on the same machine as the database server. If not, you could use the READ_CLIENT_FILE procedure but that would require a more involved setup.

(03 Jun, 13:39) Chris Keating
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 02 Jun, 07:54

question was seen: 150 times

last updated: 03 Jun, 13:39