开发者

Error using osql.exe (Sql Server 2005)

I use sql server 2005 enterprise, windows server 2003.

I try execute osql.exe command, for execute sql file in my server DESSQL:

osql.exe -E -n-1 -i"CarpetaUno\TextFile1.sql"

I get this error:

Msg 102, Level 15, State 1, Server DESSQL, Line 1
Incorrect syntax near 'n'

UPDATE:

I try this too,

osql.exe -E -i"CarpetaUno\TextFile1.sql"

1> 2> Msg 102, Level 15, State 1, Server DESSQL, Line 1
Incorrect syntax near 'n'

Finally, I use SQLCMD command:

SQLCMD -E -b -i"CarpetaUno\TextFile1.sql"

But not works using osql command !!

I test:

1.) using -S ServerName option,

2.) using absolute path: osql.exe -E --i C:\CarpetaUno\TextFile1.sql

3.) TextFile1.sql contents, is OK, I test using SSMS

CREATE DATABASE PRUEBA;

DROP DATABASE PRUEBA;

but I get the sam开发者_Go百科e error, in all tests.

Can it fails if I use utf-8 encoding in file ???

any solutions?


I think you're barking up the wrong tree..

Error 102 is incorrect SQL syntax, more than likely from the source SQL file.

Update
I think you've answered your own question.. OSQL accepts ANSI and Unicode encoded files, BUT I tried opening my file with notepad++ changed the encoding to UTF-8 and I got similar errors.

A quick google gave me this and this with a little bit more information.

The bottom line is: Use SQLCMD.exe


The -n option removes the 1> 2> ... line number prompts and afaik there are no other flags that go along with it so remove the -1.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜