underscore
underscore

Reputation: 6887

How to store multiline sql query in a shell variable?

How can i hold multiline sql query in a shell variable?

SQL='Lets get CREATE TRIGGER STATEMENT'

How to hold it?

Upvotes: 1

Views: 1490

Answers (2)

Srini V
Srini V

Reputation: 11365

This worked well for me

  extract_sql="SELECT *
               FROM TABLE"

To run SQLs with command line tools like wxsubmit or sqlplus

 commandlinesqltool  -options << EOF > /dev/null 2>&1

    SET HEADER OFF

    UPDATE TABLE
    SET    A=1;

EOF

Upvotes: 1

koushik veldanda
koushik veldanda

Reputation: 1107

Declare @sql nvarchar(max);

SET @sql='SELECT *'+char(13) +'FROM table'

Print(@sql);


result: SELECT *
        FROM table

In above query char(13) will hepls to write in next line.

Now @sql variable has two lines.

Upvotes: 0

Related Questions