Showing posts with label utility. Show all posts
Showing posts with label utility. Show all posts

Monday, March 12, 2012

osql.exe

Hi,
I am using the osql utility from two different machines,
both in the same workgroup and on the same network
segment. When running osql -L, workstation1 reports two
available servers, while workstation2 reports 6 available
servers. Where does the osql utility pull server
information from when the -L switch is used?
ActiveDirectory?
Local machine registry?
broadcast?
Thanks,
JohnNetwork broadcast.
OSQL -L uses the ODBC SQLBrowseConnect functionality. It's
not guaranteed to give a complete list due to broadcast
issues, network routers/subnet issues, instances may not
respond within the timeout period, etc. You can find issues
listed here:
http://www.sqldev.net/misc/ListSQLSvr.htm
-Sue
On Wed, 10 Mar 2004 11:06:07 -0800, "John"
<anonymous@.discussions.microsoft.com> wrote:

>Hi,
>I am using the osql utility from two different machines,
>both in the same workgroup and on the same network
>segment. When running osql -L, workstation1 reports two
>available servers, while workstation2 reports 6 available
>servers. Where does the osql utility pull server
>information from when the -L switch is used?
>ActiveDirectory?
>Local machine registry?
>broadcast?
>Thanks,
>John
>

OSQL vs Enterprise Manager

Can I say that osql is a cmd-line utility of GUI
Enterprise Manager?
Would you please list the Pros and Cons of them?
Thanks!
Hi,
With OSQL you can do all the TSQL commands, but you have to type in your
commands, where as in Enterprise manager you could do all the tasks by mouse
click. I recommend you to use either Query analyzer or OSQL, this will
increase your knowledge.
FYI, We can not say any pros and cons...between both of them
One disadvantage in Enterprise manager:
If you add a column in a table, EM will unload the data , script the table,
change it to new and load the data back. Where as OSQL .. ALTER Table
command just
adds the column directly into the table.
Thanks
Hari
MCDBA
"AW" <anonymous@.discussions.microsoft.com> wrote in message
news:0dd601c4993a$837d5b00$a501280a@.phx.gbl...
> Can I say that osql is a cmd-line utility of GUI
> Enterprise Manager?
> Would you please list the Pros and Cons of them?
> Thanks!

OSQL Utility to connect to the SQL Server.

Hi
Can I just use OSQL in one of my PC which does't have SQL
client to connect to one of the SQL Server?
i.e. I am trying to connect an SQL Server from one of my
PC. In that PC I don't have SQL Client. I don't want to
install SQL Client also. But it is enough to use the OSQL
utility to connect to the SQL Server.
Any answer?
Thanks in advance
Anand.I guess you can try to copy only OSQL.EXE to that machine. But chances are
that is uses some DLL, but you would notice that... Note that you require an
SQL Server Client license per the license agreement to do this.
--
Tibor Karaszi, SQL Server MVP
Archive at:
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"Anand" <gurusanand@.yahoo.com> wrote in message
news:0a3f01c3a9af$d9a1dae0$a301280a@.phx.gbl...
> Hi
> Can I just use OSQL in one of my PC which does't have SQL
> client to connect to one of the SQL Server?
> i.e. I am trying to connect an SQL Server from one of my
> PC. In that PC I don't have SQL Client. I don't want to
> install SQL Client also. But it is enough to use the OSQL
> utility to connect to the SQL Server.
> Any answer?
> Thanks in advance
> Anand.|||Tibor Karaszi wrote:
> I guess you can try to copy only OSQL.EXE to that machine. But
> chances are that is uses some DLL, but you would notice that... Note
> that you require an SQL Server Client license per the license
> agreement to do this.
Hi guys.
Anand, I believe the following are needed to run osql.exe (although I
havent tested it yet). Obviously from this list you will notice that
most are either transport files (part of the OS) and OS specific files.
They will obviously need to be registered with the OS.
On a fresh system you will probably only need to install the latest
MDAC and then you should be able to run osql, although not sure the
sqlsrv32.dll is installed by MDAC or through SQL Client install so if
the latter is the case you will need to copy and register this.
Please take note of tibor's comments that a client seat license will
probably still be needed.
osql.exe
C:\WINNT\system32\...
odbc32.dll
odbcint.dll
sqlsrv32.dll
NETAPI32.DLL
secur32.dll
netrap.dll
samlib.dll
ws2_32.dll
ws2help.dll
dnsapi.dll
wsock32.dll
sqlunirl.dll
WINSPOOL.DRV
OLE32.DLL
NDDEAPI.DLL
sqlsrv32.rll
odbccp32.dll
dbnetlib.dll
security.dll
msapsspc.dll
SCHANNEL.DLL
msnsspc.dll
digest.dll
MSV1_0.DLL
ntdsapi.dll
msafd.dll
wshtcpip.dll
RNR20.DLL
IPHLPAPI.DLL
icmp.dll
mprapi.dll
activeds.dll
adsldpc.dll
rtutils.dll
SETUPAPI.DLL
USERENV.DLL
RASAPI32.DLL
RASMAN.DLL
TAPI32.DLL
DHCPCSVC.DLL
software.LOG
rtutils.dll
winrnr.dll
rasadhlp.dll
--
Br,
Mark Broadbent
mcdba , mcse+i
=============

osql utility dependency

Hi,
Does the command-line utility osql.exe has any external dependencies?
I'm building a java installer that needs to interact with MSSQL with
osql.exe. Now the temporary solution is to ensure the machine on which
the installer is run has either MSDE or MSSQL client installed, but that
is clearly not a long-term solution. Can i just take osql.exe and
package it into my installer so that i can interact with MSSQL database
server without MSDE or MSSQL client installed?You can't just take osql.exe and package it in the installer, as you are not
allowed to redistribute it. But anything you can do with osql.exe, you can
do with JDBC as well.
Jacco Schalkwijk
SQL Server MVP
"Zhu Bo" <bo.zhu@.encentuate.om> wrote in message
news:%2375I4hENFHA.3420@.tk2msftngp13.phx.gbl...
> Hi,
> Does the command-line utility osql.exe has any external dependencies? I'm
> building a java installer that needs to interact with MSSQL with osql.exe.
> Now the temporary solution is to ensure the machine on which the installer
> is run has either MSDE or MSSQL client installed, but that is clearly not
> a long-term solution. Can i just take osql.exe and package it into my
> installer so that i can interact with MSSQL database server without MSDE
> or MSSQL client installed?

osql utility

Hi all
I am using osql utility in sql server 2000 to convert data in database to excel sheet. My datas contain both english and chinese . While converting to excel sheet english datas are comming but the datas in chinese is comming like (?) this. Does any body has any idea to solve this problem. is there any way to set font in osql utility.

set @.x = 'osql -S servername -U username -P password -q "select * from

northwind..region" -w 3000 -s "," -o C:\Download\download.csv'
This is what i have used.
Note: I tried giving chinese font in excel still it is not working.
Its really urgent pls reply
thanksHave you tried using the -u parameter of OSQL.EXE to force Unicode output? That would be needed for Chinese characters.

-PatP|||What version of Excel are u using Have u turned on Multilingual

osql utility

using osql utility i have converted a table in database to excel format. I have also chinese data in my database . The problem is while converting the data into excel format ,the chinese data is not comming in excel sheet.
Does anybody have an idea about this .
For converting i have used

declare @.x varchar(300)
set @.x = 'osql -S Servername -U username -P passwd -q "select * from northwind..region order by cand_index" -w 3000 -s "," -o C:\directory\filename.csv'

ThanksDid you try using BCP instead and may be try using 950 codepage as a one of the switches . eg. -C950

something like

bcp "Select * from Northwind.dbo.region" queryout "D:\temp\filename.csv" -c -T -C950

Use other switches to specify field seperator -t etc

let know how it goes

...|||I would add a -u parameter to your OSQL command.

-PatP

Friday, March 9, 2012

osql syntax

Hi
I am running osql utility like this...
C:\Temp>osql -U sa -P 5a -S %ServerName% -d pubs -Q "select title, notes
from titles" -o .\out.txt -s"," -w300 -h-1
And it produces the following in "out.txt":
== start of output ==
The Busy Executive's Database Guide
,An overview of available database systems with emphasis on common business
applications. Illustrated.
...
...
...
Sushi, Anyone?
,Detailed instructions on how to make authentic Japanese sushi in your spare
time.
(18 rows affected)
== end of output ==
Can anybody tell me
(a) how to remove the "(18 rows affected)" comment
(b) how to remove the %FieldValue% right padding. Ideally I'd like the
output to be
== start of output ==
%FieldValue%,%FieldValue%
%FieldValue%,%FieldValue%
== end of output ==
Thanks for any tips.
PS My actual queries will be bigger than bcp allows. I'd prefer not to have
to write the query as:
select '"' + title + '", "' + notes + '"' from titles
Cheers,
Neil Evans-Mudie
-. . .. .-.. / .--. ... -- -. .. -.-. .--. / . ...- .- -.
... -...- -- ..- -.. .. .
e: My@.myorg.com address is a spam sink
If you wish to email me, try neilevans underscore mudie at hotmail dot com
w: http://groups.msn.com/TheEvansMudieF...ew.msnw?&pps=k
Neil
to avoid the rowcount, you can use -Q "set nocount on select title, notes
from titles". As far as I understand, you can't avoid the fixed width nature
of the output, apart from the concatenation solution you propose.
HTH,
Paul Ibison

osql syntax

Hi
I am running osql utility like this...
C:\Temp>osql -U sa -P 5a -S %ServerName% -d pubs -Q "select title, notes
from titles" -o .\out.txt -s"," -w300 -h-1
And it produces the following in "out.txt":
== start of output ==
The Busy Executive's Database Guide
,An overview of available database systems with emphasis on common business
applications. Illustrated.
...
...
...
Sushi, Anyone?
,Detailed instructions on how to make authentic Japanese sushi in your spare
time.
(18 rows affected)
== end of output ==
Can anybody tell me
(a) how to remove the "(18 rows affected)" comment
(b) how to remove the %FieldValue% right padding. Ideally I'd like the
output to be
== start of output ==
%FieldValue%,%FieldValue%
%FieldValue%,%FieldValue%
== end of output ==
Thanks for any tips.
PS My actual queries will be bigger than bcp allows. I'd prefer not to have
to write the query as:
select '"' + title + '", "' + notes + '"' from titles
Cheers,
Neil Evans-Mudie
-. . .. .-.. / .--. ... -- -. .. -.-. .--. / . ...- .- -.
... -...- -- ..- -.. .. .
e: My@.myorg.com address is a spam sink
If you wish to email me, try neilevans underscore mudie at hotmail dot com
w: http://groups.msn.com/TheEvansMudie...new.msnw?&pps=kNeil
to avoid the rowcount, you can use -Q "set nocount on select title, notes
from titles". As far as I understand, you can't avoid the fixed width nature
of the output, apart from the concatenation solution you propose.
HTH,
Paul Ibison

osql syntax

Hi
I am running osql utility like this...
C:\Temp>osql -U sa -P 5a -S %ServerName% -d pubs -Q "select title, notes
from titles" -o .\out.txt -s"," -w300 -h-1
And it produces the following in "out.txt":
== start of output ==
The Busy Executive's Database Guide
,An overview of available database systems with emphasis on common business
applications. Illustrated.
...
...
...
Sushi, Anyone?
,Detailed instructions on how to make authentic Japanese sushi in your spare
time.
(18 rows affected)
== end of output ==
Can anybody tell me
(a) how to remove the "(18 rows affected)" comment
(b) how to remove the %FieldValue% right padding. Ideally I'd like the
output to be
== start of output ==
%FieldValue%,%FieldValue%
%FieldValue%,%FieldValue%
== end of output ==
Thanks for any tips.
PS My actual queries will be bigger than bcp allows. I'd prefer not to have
to write the query as:
select '"' + title + '", "' + notes + '"' from titles
Cheers,
Neil Evans-Mudie
-. . .. .-.. / .--. ... -- -. .. -.-. .--. / . ...- .- -.
... -...- -- ..- -.. .. .
e: My@.myorg.com address is a spam sink
If you wish to email me, try neilevans underscore mudie at hotmail dot com
w: http://groups.msn.com/TheEvansMudieFamily/_whatsnew.msnw?&pps=kNeil
to avoid the rowcount, you can use -Q "set nocount on select title, notes
from titles". As far as I understand, you can't avoid the fixed width nature
of the output, apart from the concatenation solution you propose.
HTH,
Paul Ibison

OSQL spelling mistake?

Hi,
has anybody else noticed a spelling mistake when using OSQL utility with the
-E -L switches. It reads The -L parameter can not be used in combineation
with others parameters
Robin
Robin (Robin@.discussions.microsoft.com) writes:
> has anybody else noticed a spelling mistake when using OSQL utility with
> the -E -L switches. It reads The -L parameter can not be used in
> combineation with others parameters
Apparently :-) It has been fixed in SQL 2005.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx

Wednesday, March 7, 2012

OSQL didnt like rookies

Sory for fullish question,but i'm coming from DB2 and Oracle world,and not SQL world.
How I can understand,OSQL utility is command-line utility in SQL server.So,I tried to start it,but it failed with error:
Login failed for user 'Administrator'. Reason: Not associated with a trusted SQL Server connection.

There is some properties for my sqlserver:
Authentication is "Windows only".User Administrator is admin on machine.In Windows services,there is one servis ( started) and logon for that service is Administrator.In fact,my SQL server works fine,because other GUIs works ok.
SQLSERVERNAME=hostname=navtest.
I tried to logon by entering in cmd this
osql -S NAVTEST
but every time I see error :
Login failed for user 'Administrator'. Reason: Not associated with a trusted SQL Server connection.
What i am doing wrong?
Every help will be greatJust because the sql service runs under the Administrator's account doesn't meen the Administrator can log onto the SQL Server.

By default, the Microsoft SQL Server setup creates the "BUILTIN\Administrators" login, which gives any account in the Local Administrators group system administrator (sa) privileges. Most people delete this account, could be the problem you are facing.

You can add the local Admin account back and grant that account sa privileges.|||Thanks,Paul!
I entered osql -s <servername> -E and it works!
Now,I tried to enter some commands,but I don't know how to end it.
I tried this:
1> select * from northwind......
2>
3> /
4>

Now,how You say to SQLSERVER execute commands?

Thanks a lot,Zvonimir|||hum... when you tried the -E what userid had you logged in with?

go terminates a block of commands.|||I find that switch -E by searching this forum...
And GO really works!!!

Thanks,Zvonimir|||Could have also found it by looking in Books Online. You can also change the command terminator with the -c switch.

btw, what userid were you using when you had success with the -E switch, Administrator?|||-E switch explicitly specifies your intent to log on using trusted connection. The default behavior for OSQL is to use Standard SQL Server Security. That's why Z was getting his(/her) error at the beginning. With -E switch the logon succeeded using security context of the currently logged on user, - Administrator.

Saturday, February 25, 2012

OSQL

Creating a utility that will allow a user to run a query from a BAT file.
BUT the SQL client is not installed on all PCs. How can I modify this to
run, or what must I do in order for this to work from PCs with no SQL client
'
osql -E -S EXCEDE\EXCEDE -d excede_Reporting -q"EXIT(exec isp_SetCrPw %1)"Hi,
you would probably have to write your own application for this using
e.g. .NET. That should be quite easy, as the only thing would be to
have a argument parser in place, the rest is only some simply
SqlConnection and SqlCommand.
HTH, Jens K. Suessmeyer.
--
http://www.sqlserver2005.de
--|||That would be beyond my current abilities. I can write some very simple
scripts, and I have a mild understanding of some VB and .NET, But to write
my own code. Well I have no idea where to start. If you would like to help
and get me started I would greatly appreciate and enjoy the experience.
Thanks.
==============================================="Jens" <Jens@.sqlserver2005.de> wrote in message
news:1171392808.470036.289720@.j27g2000cwj.googlegroups.com...
> Hi,
> you would probably have to write your own application for this using
> e.g. .NET. That should be quite easy, as the only thing would be to
> have a argument parser in place, the rest is only some simply
> SqlConnection and SqlCommand.
>
> HTH, Jens K. Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
>|||Lets take that offline and write me an Email.|||WANNABE;7269311 Wrote:
> That would be beyond my current abilities. I can write some very
> simple
> scripts, and I have a mild understanding of some VB and .NET, But to
> write
> my own code. Well I have no idea where to start. If you would like to
> help
> and get me started I would greatly appreciate and enjoy the
> experience.
> Thanks.
> ===============================================> "Jens" <Jens@.sqlserver2005.de> wrote in message
> news:1171392808.470036.289720@.j27g2000cwj.googlegroups.com...
> > Hi,
> >
> > you would probably have to write your own application for this using
> > e.g. .NET. That should be quite easy, as the only thing would be to
> > have a argument parser in place, the rest is only some simply
> > SqlConnection and SqlCommand.
> >
> >
> > HTH, Jens K. Suessmeyer.
> >
> > --
> > http://www.sqlserver2005.de
> > --
> >
I have written an OSQL like replacement in C#/.Net 2.0. I am
having a wee bit of an issue though. If the SQL file to be run
has dynamic SQL in it (building SQL strings and then executing
them) then the command will fail - always. I think it has
something to do with the nesting of the quotes. Got any ideas
on what would be causing something like this?
Thanks
escher4096

OSQL

Creating a utility that will allow a user to run a query from a BAT file.
BUT the SQL client is not installed on all PCs. How can I modify this to
run, or what must I do in order for this to work from PCs with no SQL client
?
osql -E -S EXCEDE\EXCEDE -d excede_Reporting -q"EXIT(exec isp_SetCrPw %1)"
Hi,
you would probably have to write your own application for this using
e.g. .NET. That should be quite easy, as the only thing would be to
have a argument parser in place, the rest is only some simply
SqlConnection and SqlCommand.
HTH, Jens K. Suessmeyer.
http://www.sqlserver2005.de
|||That would be beyond my current abilities. I can write some very simple
scripts, and I have a mild understanding of some VB and .NET, But to write
my own code. Well I have no idea where to start. If you would like to help
and get me started I would greatly appreciate and enjoy the experience.
Thanks.
===============================================
"Jens" <Jens@.sqlserver2005.de> wrote in message
news:1171392808.470036.289720@.j27g2000cwj.googlegr oups.com...
> Hi,
> you would probably have to write your own application for this using
> e.g. .NET. That should be quite easy, as the only thing would be to
> have a argument parser in place, the rest is only some simply
> SqlConnection and SqlCommand.
>
> HTH, Jens K. Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
>
|||Lets take that offline and write me an Email.
|||

Quote:

Originally Posted by WANNABEView Post

That would be beyond my current abilities. I can write some very simple
scripts, and I have a mild understanding of some VB and .NET, But to write
my own code. Well I have no idea where to start. If you would like to help
and get me started I would greatly appreciate and enjoy the experience.
Thanks.
===============================================
"Jens" <Jens@.sqlserver2005.de> wrote in message
news:1171392808.470036.289720@.j27g2000cwj.googlegr oups.com...
> Hi,
> you would probably have to write your own application for this using
> e.g. .NET. That should be quite easy, as the only thing would be to
> have a argument parser in place, the rest is only some simply
> SqlConnection and SqlCommand.
>
> HTH, Jens K. Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
>

I have written an OSQL like replacement in C#/.Net 2.0. I am
having a wee bit of an issue though. If the SQL file to be run
has dynamic SQL in it (building SQL strings and then executing
them) then the command will fail - always. I think it has
something to do with the nesting of the quotes. Got any ideas
on what would be causing something like this?
Thanks

OSQL

Creating a utility that will allow a user to run a query from a BAT file.
BUT the SQL client is not installed on all PCs. How can I modify this to
run, or what must I do in order for this to work from PCs with no SQL client
'
osql -E -S EXCEDE\EXCEDE -d excede_Reporting -q"EXIT(exec isp_SetCrPw %1)"Hi,
you would probably have to write your own application for this using
e.g. .NET. That should be quite easy, as the only thing would be to
have a argument parser in place, the rest is only some simply
SqlConnection and SqlCommand.
HTH, Jens K. Suessmeyer.
http://www.sqlserver2005.de
--|||That would be beyond my current abilities. I can write some very simple
scripts, and I have a mild understanding of some VB and .NET, But to write
my own code. Well I have no idea where to start. If you would like to help
and get me started I would greatly appreciate and enjoy the experience.
Thanks.
========================================
=======
"Jens" <Jens@.sqlserver2005.de> wrote in message
news:1171392808.470036.289720@.j27g2000cwj.googlegroups.com...
> Hi,
> you would probably have to write your own application for this using
> e.g. .NET. That should be quite easy, as the only thing would be to
> have a argument parser in place, the rest is only some simply
> SqlConnection and SqlCommand.
>
> HTH, Jens K. Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
>|||Lets take that offline and write me an Email.|||WANNABE;7269311 Wrote:[vbcol=seagreen]
> That would be beyond my current abilities. I can write some very
> simple
> scripts, and I have a mild understanding of some VB and .NET, But to
> write
> my own code. Well I have no idea where to start. If you would like to
> help
> and get me started I would greatly appreciate and enjoy the
> experience.
> Thanks.
> ========================================
=======
> "Jens" <Jens@.sqlserver2005.de> wrote in message
> news:1171392808.470036.289720@.j27g2000cwj.googlegroups.com...
I have written an OSQL like replacement in C#/.Net 2.0. I am
having a wee bit of an issue though. If the SQL file to be run
has dynamic SQL in it (building SQL strings and then executing
them) then the command will fail - always. I think it has
something to do with the nesting of the quotes. Got any ideas
on what would be causing something like this?
Thanks
escher4096