Saturday, February 25, 2012

osql :r filename

Hello,
somebody have already used this option od osql ==> :r filename
Could you give me some example
thanksPut below in a bat file. It will create an inner script file as sell as an o
uter script file and
then call OSQL with the outer script file as input file.
ECHO SELECT 'Inner script' > inner.sql
ECHO SELECT 'Outer Script before' > outer.sql
ECHO :r inner.sql >> outer.sql
ECHO SELECT 'Outer cript after' >> outer.sql
OSQL /E /i outer.sql
PAUSE
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"ft" <ft@.discussions.microsoft.com> wrote in message
news:E3423CEB-A2B3-4140-9971-B6D31905BF15@.microsoft.com...
> Hello,
> somebody have already used this option od osql ==> :r filename
> Could you give me some example
> thanks|||Thanks for your response.
I try to run the scrip "all.sql" which contains 2 other scripts . scr1.sql
and scr2.sql
these scripts contains "go" statement".
there is the contain of "all.sql"
:r scr1.sql
:r scr2.sql
when I run this command on line
osql -S Server -d my base -U my user -P my pass -i all.sql -o out.txt
I obtain the error message : "Incorrect syntax near 'GO'.
If I run the scr1.sql directly from a command line, that is ok. There is no
error message.
Do you have any idea about this problem.
Thanks
"Tibor Karaszi" wrote:

> Put below in a bat file. It will create an inner script file as sell as an
outer script file and
> then call OSQL with the outer script file as input file.
> ECHO SELECT 'Inner script' > inner.sql
> ECHO SELECT 'Outer Script before' > outer.sql
> ECHO :r inner.sql >> outer.sql
> ECHO SELECT 'Outer cript after' >> outer.sql
> OSQL /E /i outer.sql
> PAUSE
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "ft" <ft@.discussions.microsoft.com> wrote in message
> news:E3423CEB-A2B3-4140-9971-B6D31905BF15@.microsoft.com...
>
>|||An inner script called by OSQL using :r cannot contain GO, I'm afraid...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"ft" <ft@.discussions.microsoft.com> wrote in message
news:98DBCA95-E826-48D3-BE60-1D10EBFC8E79@.microsoft.com...[vbcol=seagreen]
> Thanks for your response.
> I try to run the scrip "all.sql" which contains 2 other scripts . scr1.sql
> and scr2.sql
> these scripts contains "go" statement".
> there is the contain of "all.sql"
> :r scr1.sql
> :r scr2.sql
> when I run this command on line
> osql -S Server -d my base -U my user -P my pass -i all.sql -o out.txt
> I obtain the error message : "Incorrect syntax near 'GO'.
> If I run the scr1.sql directly from a command line, that is ok. There is n
o
> error message.
> Do you have any idea about this problem.
> Thanks
>
> "Tibor Karaszi" wrote:
>

No comments:

Post a Comment