Showing posts with label osql. Show all posts
Showing posts with label osql. Show all posts

Wednesday, March 21, 2012

Out Of Memory

Hi Guys,
What i'm trying here is to run a .bat file containing Osql Command's on the server using asp. Which is Generating Out Of Memory Error.

In Detail.

This .bat file is having a Osql command to connect to a database with a parameter to run a .sql file and output parameter to give to output in .txt file. This is working fine if I simply run the .bat file on the server. its working fine no probes, but when I try the same from a .asp file running this .asp file from the same machine its giving me the Out of Memory Error.


Content of the .bat file is
@.cd
@.osql -U user -P Password -i c:\BatchUpdateTest\test.sql -o c:\BatchUpdateTest\test.txt
@.pause


Content of the .sql file is
SELECT * INTO ARC_TABLENAME TABLENAME
GO

DECLARE @.del_error int
DECLARE @.description VARCHAR(1000)

SELECT @.del_error= @.@.ERROR
SELECT @.description= description FROM MASTER..SYSMESSAGES WHERE error = @.del_error

IF @.del_error = 0
SELECT * FROM ARC_TABLENAME
ELSE
PRINT @.description+' ARC_TABLENAME'
GO


Content of the .asp file is

<%
var server_shell = Server.CreateObject("wscript.shell")
try{
server_shell.Run("c:\BatchUpdateTest\test.bat",1)
}catch(e){
Response.Write(e.description)
}
%>



Actualy when i run this code in the .bat file from .asp it did not give any error. So what i did is put a try catch block to trap the error which gives me this error Out of memory.

What should i do to solve this problem
Plz Help me out in this

Thanks in advance
Dinesh

I can't tell exactly what is going on here, but it seems to be limited to the web access method, since it works correctly from the batch file. So I would limit my search to that area - you might want to try turning on garbage collection:

http://support.microsoft.com/kb/911716

Buck Woody

Out of Memory

Hi Guys,
What i'm trying here is to run a .bat file containing Osql Command's on the server using asp. Which is Generating Out Of Memory Error.

In Detail.

This .bat file is having a Osql command to connect to a database with a parameter to run a .sql file and output parameter to give to output in .txt file. This is working fine if I simply run the .bat file on the server. its working fine no probes, but when I try the same from a .asp file running this .asp file from the same machine its giving me the Out of Memory Error.


Content of the .bat file is
@.cd
@.osql -U user -P Password -i c:\BatchUpdateTest\test.sql -o c:\BatchUpdateTest\test.txt
@.pause

Content of the .sql file is
SELECT * INTO ARC_TABLENAME TABLENAME
GO

DECLARE @.del_error int
DECLARE @.description VARCHAR(1000)

SELECT @.del_error= @.@.ERROR
SELECT @.description= description FROM MASTER..SYSMESSAGES WHERE error = @.del_error

IF @.del_error = 0
SELECT * FROM ARC_TABLENAME
ELSE
PRINT @.description+' ARC_TABLENAME'
GO


Content of the .asp file is
<%
var server_shell = Server.CreateObject("wscript.shell")
try{
server_shell.Run("c:\BatchUpdateTest\test.bat",1)
}catch(e){
Response.Write(e.description)
}
%>

Actualy when i run this code in the .bat file from .asp it did not give any error. So what i did is put a try catch block to trap the error which gives me this error Out of memory.

What should i do to solve this problem
Plz Help me out in this

Thanks in advance
Dinesh
You need to troubleshoot from ASP side. It is unlikely this has anything to do with SQL or the batch file itself.

Out Of Memory

Hi Guys,
What i'm trying here is to run a .bat file containing Osql Command's on the server using asp. Which is Generating Out Of Memory Error.

In Detail.

This .bat file is having a Osql command to connect to a database with a parameter to run a .sql file and output parameter to give to output in .txt file. This is working fine if I simply run the .bat file on the server. its working fine no probes, but when I try the same from a .asp file running this .asp file from the same machine its giving me the Out of Memory Error.


Content of the .bat file is
@.cd
@.osql -U user -P Password -i c:\BatchUpdateTest\test.sql -o c:\BatchUpdateTest\test.txt
@.pause


Content of the .sql file is
SELECT * INTO ARC_TABLENAME TABLENAME
GO

DECLARE @.del_error int
DECLARE @.description VARCHAR(1000)

SELECT @.del_error= @.@.ERROR
SELECT @.description= description FROM MASTER..SYSMESSAGES WHERE error = @.del_error

IF @.del_error = 0
SELECT * FROM ARC_TABLENAME
ELSE
PRINT @.description+' ARC_TABLENAME'
GO


Content of the .asp file is

<%
var server_shell = Server.CreateObject("wscript.shell")
try{
server_shell.Run("c:\BatchUpdateTest\test.bat",1)
}catch(e){
Response.Write(e.description)
}
%>



Actualy when i run this code in the .bat file from .asp it did not give any error. So what i did is put a try catch block to trap the error which gives me this error Out of memory.

What should i do to solve this problem
Plz Help me out in this

Thanks in advance
Dinesh

I can't tell exactly what is going on here, but it seems to be limited to the web access method, since it works correctly from the batch file. So I would limit my search to that area - you might want to try turning on garbage collection:

http://support.microsoft.com/kb/911716

Buck Woody

Monday, March 12, 2012

osql.exe

Is there some registry key that tell me if and where osql.exe is lcoated?
--
Sincerely
Andrea Morohi Andrea,
"Andrea Moro" <moroandreaET@.tiscalinet.it> ha scritto nel messaggio
news:%23JY7YyJcDHA.616@.TK2MSFTNGP11.phx.gbl...
> Is there some registry key that tell me if and where osql.exe is lcoated?
have a look at HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\80\
SharedCode key which should point to
c:\program files\Microsor SQL Server\80\Tools\
or HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\80\Tools\ClientSetup
SQLPAth key which should point to
c:\program files\Microsor SQL Server\80\Tools\
just consider oSql.exe resides in the Binn subfoler...
hth
Andrea Montanari
andrea.sql@.virgilio.it
montanari_andrea@.virgilio.it
http://www.asql.biz/DbaMgr.shtm
DbaMgr2k ver 0.4.0 - DbaMgr ver 0.50.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply|||Refer to this url
http://www.vb2themax.com/Item.asp?PageID=CodeBank&ID=688
--
-Vishal
"Andrea Moro" <moroandreaET@.tiscalinet.it> wrote in message
news:#JY7YyJcDHA.616@.TK2MSFTNGP11.phx.gbl...
> Is there some registry key that tell me if and where osql.exe is lcoated?
> --
> Sincerely
> Andrea Moro
>|||with t-sql you can have something like this:
create table #test (value varchar(500), data varchar(500))
nsert into #test
exec master..xp_regread N'HKEY_LOCAL_MACHINE',N'SOFTWARE\Microsoft\Microsoft
SQL Server\80\Tools\ClientSetup', N'SQLPath'
select data + '\bin' as 'osql_path' from #test
--
-Vishal
"Vishal Parkar" <vgparkar@.hotmail.com> wrote in message
news:e0ysoXKcDHA.2688@.TK2MSFTNGP11.phx.gbl...
> Refer to this url
> http://www.vb2themax.com/Item.asp?PageID=CodeBank&ID=688
> --
> -Vishal
> "Andrea Moro" <moroandreaET@.tiscalinet.it> wrote in message
> news:#JY7YyJcDHA.616@.TK2MSFTNGP11.phx.gbl...
> > Is there some registry key that tell me if and where osql.exe is
lcoated?
> >
> > --
> > Sincerely
> > Andrea Moro
> >
> >
>

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 works with SQL Server 6.5 ??

some knows if osql (or isql) works well with SQL Server 6.5
Hi,
ISQL will work with SQL 6.5.
OSQL will not work with SQL 6.5, it works only with the newer versions.
Thanks
Hari
MCDBA
"Pablo Garateguy" <anonymous@.discussions.microsoft.com> wrote in message
news:B5B8DC9E-1D10-4D71-B0D8-16507FC85921@.microsoft.com...
> some knows if osql (or isql) works well with SQL Server 6.5
|||Hari,
have you tested this? It would seem that osql should work with SQL Server
6.5. It is just an ODBC application and as such should work as any other
ODBC application would work.
Rand
This posting is provided "as is" with no warranties and confers no rights.
|||Hi,
Excution I agree. OSQL will work with SQL 6.5
But OSQL utlity is only coming along with newer version. SQL 6.5
installation will not have an OSQL.
That is what I meant.
Thanks
Hari
MCDBA
"Rand Boyd [MSFT]" <rboyd@.onlinemicrosoft.com> wrote in message
news:D0M9fAmQEHA.796@.cpmsftngxa10.phx.gbl...
> Hari,
> have you tested this? It would seem that osql should work with SQL Server
> 6.5. It is just an ODBC application and as such should work as any other
> ODBC application would work.
> Rand
> This posting is provided "as is" with no warranties and confers no rights.
>

osql with Unicode ?

Hi
How can I insert data in sql file(unicode - Thai chars) into sql server
using osql ?
regards
Dishan
Whe I run these files(inserts) using osql, enterprise manager shows
"?" as data
please help..
|||Sorry its my mistake.. I didnt put N( N'unidata' ) in my sql script

osql with script trouble...

I have a sql file that contains:
if EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name ='newShopcart')
DROP DATABASE [newShopcart];
CREATE DATABASE [newShopcart] ON (NAME ='newShopcart_dat', FILENAME ='C:\MSSQL7\DATA\newShopcart.mdf' , SIZE = 10, FILEGROWTH =
10%) LOG ON (NAME ='newShopcart_log', FILENAME ='C:\MSSQL7\DATA\newShopcart.ldf' , SIZE = 10, FILEGROWTH = 10%);
USE [newShopcart];
GO
And I call this using osql in this way:
osql -D TLC -U sa -P thepassword -i MakeDB.sql -o MakeDB.log -n
I get the following in the resulting log:
Msg 2812, Level 16, State 62, Line 1
Could not find stored procedure 'i'.
I've noticed that changing the first line to USE [master] changes the log to:
Msg 2812, Level 16, State 62, Line 1
Could not find stored procedure 'U'.
This leads me to believe that it sees the first character of the file as the name of a Stored Procedure.
Any idea how to get around this?
Thanks in advance.
Mandy wrote:
> I have a sql file that contains:
> if EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name
> ='newShopcart')
> DROP DATABASE [newShopcart];
> CREATE DATABASE [newShopcart] ON (NAME ='newShopcart_dat', FILENAME
> ='C:\MSSQL7\DATA\newShopcart.mdf' , SIZE = 10, FILEGROWTH = 10%) LOG
> ON (NAME ='newShopcart_log', FILENAME
> ='C:\MSSQL7\DATA\newShopcart.ldf' , SIZE = 10, FILEGROWTH = 10%);
> USE [newShopcart];
> GO
> And I call this using osql in this way:
> osql -D TLC -U sa -P thepassword -i MakeDB.sql -o MakeDB.log -n
> I get the following in the resulting log:
> Msg 2812, Level 16, State 62, Line 1
> Could not find stored procedure 'i'.
> I've noticed that changing the first line to USE [master] changes the
> log to:
> Msg 2812, Level 16, State 62, Line 1
> Could not find stored procedure 'U'.
> This leads me to believe that it sees the first character of the file
> as the name of a Stored Procedure.
> Any idea how to get around this?
> Thanks in advance.
Does this code work from Query Analyzer? I see on your last line you
are using a semi-colon and a go. Does OSQL understand "go"? What's the
"n" option for and do you need it?
David Gugick
Imceda Software
www.imceda.com
|||It does work under QA. -n removes line numbers from results.

> Does this code work from Query Analyzer? I see on your last line you
> are using a semi-colon and a go. Does OSQL understand "go"? What's the
> "n" option for and do you need it?
> --
> David Gugick
> Imceda Software
> www.imceda.com
>
|||Are you sure this is an odbc data source and not just a regular SQL Server
connection? What happens if you remove the -D option and value? You could
also try adding the option -e to echo the commands as they are read, for
troubleshooting.
HTH
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"Mandy" <clafarge@.NOSPAMgraphiced.com> wrote in message
news:eAn4RG%232EHA.1192@.tk2msftngp13.phx.gbl...
>I have a sql file that contains:
> if EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name
> ='newShopcart')
> DROP DATABASE [newShopcart];
> CREATE DATABASE [newShopcart] ON (NAME ='newShopcart_dat', FILENAME
> ='C:\MSSQL7\DATA\newShopcart.mdf' , SIZE = 10, FILEGROWTH =
> 10%) LOG ON (NAME ='newShopcart_log', FILENAME
> ='C:\MSSQL7\DATA\newShopcart.ldf' , SIZE = 10, FILEGROWTH = 10%);
> USE [newShopcart];
> GO
> And I call this using osql in this way:
> osql -D TLC -U sa -P thepassword -i MakeDB.sql -o MakeDB.log -n
> I get the following in the resulting log:
> Msg 2812, Level 16, State 62, Line 1
> Could not find stored procedure 'i'.
> I've noticed that changing the first line to USE [master] changes the log
> to:
> Msg 2812, Level 16, State 62, Line 1
> Could not find stored procedure 'U'.
> This leads me to believe that it sees the first character of the file as
> the name of a Stored Procedure.
> Any idea how to get around this?
> Thanks in advance.
>
|||I changed to specifying -S and ip address. When I added -e, it shows only one line of output:
I
So it still appears to only see the first character of the file.
"Kalen Delaney" <replies@.public_newsgroups.com> wrote in message news:%23PyX8MA3EHA.1396@.tk2msftngp13.phx.gbl...
> Are you sure this is an odbc data source and not just a regular SQL Server
> connection? What happens if you remove the -D option and value? You could
> also try adding the option -e to echo the commands as they are read, for
> troubleshooting.
|||-S is usually followed by the server name.
What version of SQL Server? Are you running osql remotely or locally?
Can you verify the version of osql?
How did you create the .sql file?
HTH
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"Mandy" <clafarge@.NOSPAMgraphiced.com> wrote in message
news:Ogr83FH3EHA.2312@.TK2MSFTNGP15.phx.gbl...
>I changed to specifying -S and ip address. When I added -e, it shows only
>one line of output:
> I
> So it still appears to only see the first character of the file.
>
> "Kalen Delaney" <replies@.public_newsgroups.com> wrote in message
> news:%23PyX8MA3EHA.1396@.tk2msftngp13.phx.gbl...
>
|||I tried -S with ip and also server name.
MSSQL Version 7
osql on my machine, Server on network
osql version 2000.80.194.0
created script by Right-click on existing DB in Enterrprise and "Generate SQL Script", then changing names as needed for new
database.
"Kalen Delaney" <replies@.public_newsgroups.com> wrote in message news:u0bXMoH3EHA.1300@.TK2MSFTNGP14.phx.gbl...
> -S is usually followed by the server name.
> What version of SQL Server? Are you running osql remotely or locally?
> Can you verify the version of osql?
> How did you create the .sql file?
> --
> HTH
> --
> Kalen Delaney
> SQL Server MVP
> www.SolidQualityLearning.com
>
> "Mandy" <clafarge@.NOSPAMgraphiced.com> wrote in message
> news:Ogr83FH3EHA.2312@.TK2MSFTNGP15.phx.gbl...
>
|||Mandy wrote:
> I tried -S with ip and also server name.
> MSSQL Version 7
> osql on my machine, Server on network
> osql version 2000.80.194.0
> created script by Right-click on existing DB in Enterrprise and
> "Generate SQL Script", then changing names as needed for new database.
>
You really should patch your client tools. You are running the retail
release of OSQL.EXE from years ago. Apply the latest SQL Server SP3a
service pack to your client PC.
Also, try running a very simple script like "Select * from sysobjects"
from a script file and see if that works.
David Gugick
Imceda Software
www.imceda.com
|||Thanks for the pointer...
When I changed to a Select, I get:
Msg 2812, Level 16, State 62, Line 1
Could not find stored procedure 'S'.
Is there any reason why it would only see the first character?
"David Gugick" <davidg-nospam@.imceda.com> wrote in message news:uBnghHJ3EHA.524@.TK2MSFTNGP09.phx.gbl...[vbcol=seagreen]
> Mandy wrote:
|||Mandy wrote:[vbcol=seagreen]
> Thanks for the pointer...
> When I changed to a Select, I get:
> Msg 2812, Level 16, State 62, Line 1
> Could not find stored procedure 'S'.
> Is there any reason why it would only see the first character?
>
> "David Gugick" <davidg-nospam@.imceda.com> wrote in message
> news:uBnghHJ3EHA.524@.TK2MSFTNGP09.phx.gbl...
What format are you saving the file in? Is it unicode? Maybe OSQL cannot
read unicode files and requires an ANSI formatted file.
David Gugick
Imceda Software
www.imceda.com

osql with proxy account errors

I've got a proxy account set up that is working fine for DTS packages, etc.
I've also got an environmental variable set up for osql setting the user to
the proxy account. The problem I'm having is within a scheduled job, when I
execute this statement:
EXEC master..xp_cmdshell 'osql.exe -S OnyxRptServer -E -n -w 121 -Q "EXEC
SBTDataAudit.dbo.OrnumCshipnumScript" -o
" \\onyxrptserver\SBTDataAudits\Outputs\Cs
hipno_Ornum_Audit_Results.txt'
I'm getting an error saying my job owner doesn't have permissions to execute
xp_cmdshell.
My job owner is not a member of the sa server role, so I was thinking that
the proxy account user would pick up and execute the xp_cmdshell call.
Any help would be appreciated.
Thanks,
JoanFrom BOL:
"If you choose to use a Windows NT account that is not a member of the local
administrator's group for the MSSQLServer service, users who are not members
of the symin fixed server role cannot execute xp_cmdshell."
"jmeyers" wrote:

> I've got a proxy account set up that is working fine for DTS packages, etc
.
> I've also got an environmental variable set up for osql setting the user t
o
> the proxy account. The problem I'm having is within a scheduled job, when
I
> execute this statement:
> EXEC master..xp_cmdshell 'osql.exe -S OnyxRptServer -E -n -w 121 -Q "EXEC
> SBTDataAudit.dbo.OrnumCshipnumScript" -o
> " \\onyxrptserver\SBTDataAudits\Outputs\Cs
hipno_Ornum_Audit_Results.txt'
> I'm getting an error saying my job owner doesn't have permissions to execu
te
> xp_cmdshell.
> My job owner is not a member of the sa server role, so I was thinking that
> the proxy account user would pick up and execute the xp_cmdshell call.
> Any help would be appreciated.
> Thanks,
> Joan
>|||The proxy user is a local admin.
"Cris_Benge" wrote:
> From BOL:
> "If you choose to use a Windows NT account that is not a member of the loc
al
> administrator's group for the MSSQLServer service, users who are not membe
rs
> of the symin fixed server role cannot execute xp_cmdshell."
>
> "jmeyers" wrote:
>

osql will not come up MSDE (sp3) or earlier

When I try to run osql, I get the following error:
c:\program files\Microsoft SQL Server\80\Tools\Binn\

> osql -E -d CCOP or osql -U sa -P AStrongPassword -d CCOP
[Shared Memory]SQL Server does not exist or access denied.
[Shared Memory]ConnectionOpen (Connect()).
I can start the instance "CCOP" from sqlmangr without any
issue, but when I try to run osql against the database, I
can never get past the startup
-d is the switch for the database name, not the instance name. Use the -S
switch to specify the instance name.
If you are not sure of the instance name, issue a osql -L for a list of SQL
Server instances.
See
http://msdn.microsoft.com/library/de...ta_01_2r1e.asp
for more information on running the osql utility.
Terri Morton
MVP - ASP/ASP.NET
"Ed H" <anonymous@.discussions.microsoft.com> wrote in message
news:0f4301c4ff5e$4c209930$a401280a@.phx.gbl...
> When I try to run osql, I get the following error:
> c:\program files\Microsoft SQL Server\80\Tools\Binn\
>
> [Shared Memory]SQL Server does not exist or access denied.
> [Shared Memory]ConnectionOpen (Connect()).
> I can start the instance "CCOP" from sqlmangr without any
> issue, but when I try to run osql against the database, I
> can never get past the startup
|||
>--Original Message--
>-d is the switch for the database name, not the instance
name. Use the -S
>switch to specify the instance name.
>If you are not sure of the instance name, issue a osql -
L for a list of SQL
>Server instances.
>See
>http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/acdata/ac_8_mta_01_2r1e.asp
>for more information on running the osql utility.
>Terri Morton
>MVP - ASP/ASP.NET
>"Ed H" <anonymous@.discussions.microsoft.com> wrote in
message[vbcol=seagreen]
>news:0f4301c4ff5e$4c209930$a401280a@.phx.gbl...
CCOP[vbcol=seagreen]
denied.[vbcol=seagreen]
any[vbcol=seagreen]
database, I
>
>.
> Thx Terri. I had to re-install amoung other things.
The MSDN Help was a very valuable.

osql vs. QA and extended characters

Hi, I have some sql commands I incorporate into an install and I've been
using scripts and osql.exe to perform these with generally good results.
A recent addition to these installs is a script that populates a table
of usernames and encryped passwords, and this is where I'm having
trouble. If I run a script in Query Analyzer that contains this line:
insert into operator (op_code, password, first_name, last_name,
security, operator, salespoint) values ('ADMIN', '??', 'ADMIN',
'ADMIN', 9, 'SYSTEM', 'SYSTEM')
I get predictable results and the encrypted password gets correctly
decrypted in our application.
If I run the very same script using osql like this:
osql.exe -E -i MyScript.sql -o "Output.txt"
The password doesn't end up in the database as '??', it seems to get
changed to '?+-' which obviously wouldn't decrypt correctly in the
application.
So this makes me think there's some kind of translation going on with
these extended characters when running the script via osql. Anyone know
how I can achieve the same results with osql as QA? I'm hoping there's a
switch or something that will do the trick. Thanks!
Matt
MattB wrote:
> Hi, I have some sql commands I incorporate into an install and I've
> been using scripts and osql.exe to perform these with generally good
> results.
> A recent addition to these installs is a script that populates a table
> of usernames and encryped passwords, and this is where I'm having
> trouble. If I run a script in Query Analyzer that contains this line:
> insert into operator (op_code, password, first_name, last_name,
> security, operator, salespoint) values ('ADMIN', '??', 'ADMIN',
> 'ADMIN', 9, 'SYSTEM', 'SYSTEM')
> I get predictable results and the encrypted password gets correctly
> decrypted in our application.
> If I run the very same script using osql like this:
> osql.exe -E -i MyScript.sql -o "Output.txt"
> The password doesn't end up in the database as '??', it seems to
> get changed to '?+-' which obviously wouldn't decrypt correctly in
> the application.
> So this makes me think there's some kind of translation going on with
> these extended characters when running the script via osql. Anyone
> know how I can achieve the same results with osql as QA? I'm hoping
> there's a switch or something that will do the trick. Thanks!
> Matt
See this page:
http://www.windowsitpro.com/SQLServe...ver_37470.html
David Gugick
Imceda Software
www.imceda.com
|||David Gugick wrote:
> MattB wrote:
>
> See this page:
> http://www.windowsitpro.com/SQLServe...ver_37470.html
>
Great. Thanks!
Matt

osql vs Query Analyzer

We have a script with code like this
use master
go
-- do some stuff here
if exists (select name from sysdatabases where name = 'db_name')
begin
use db_name
-- do some stuff
exec storedproc
end
this works fine with Query Analyzer.
With OSQL it creates problem in the line exec storedproc. It says that
the stored procedure is not found.
we call osql as follows
osql -S servername -U username -P Password -i sqlfilename
now if we add the database name to osql
osql -S servername -U username -P Password -i sqlfilename -d db_name
it works fine.
Why should it matter. After all we are using USE statement inside the
script correctly.
How does it work in Query Analyzer.
TIA.
That should work. Can you post code which we can run that displays this?
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Data Cruncher" <dcruncher4@.netscape.net> wrote in message
news:1120679914.292796.77430@.g44g2000cwa.googlegro ups.com...
> We have a script with code like this
> use master
> go
> -- do some stuff here
> if exists (select name from sysdatabases where name = 'db_name')
> begin
> use db_name
> -- do some stuff
> exec storedproc
> end
> this works fine with Query Analyzer.
> With OSQL it creates problem in the line exec storedproc. It says that
> the stored procedure is not found.
> we call osql as follows
> osql -S servername -U username -P Password -i sqlfilename
> now if we add the database name to osql
>
> osql -S servername -U username -P Password -i sqlfilename -d db_name
> it works fine.
> Why should it matter. After all we are using USE statement inside the
> script correctly.
> How does it work in Query Analyzer.
> TIA.
>
|||Hi
You may want to use three part naming for the procedure call.
John
"Data Cruncher" wrote:

> We have a script with code like this
> use master
> go
> -- do some stuff here
> if exists (select name from sysdatabases where name = 'db_name')
> begin
> use db_name
> -- do some stuff
> exec storedproc
> end
> this works fine with Query Analyzer.
> With OSQL it creates problem in the line exec storedproc. It says that
> the stored procedure is not found.
> we call osql as follows
> osql -S servername -U username -P Password -i sqlfilename
> now if we add the database name to osql
>
> osql -S servername -U username -P Password -i sqlfilename -d db_name
> it works fine.
> Why should it matter. After all we are using USE statement inside the
> script correctly.
> How does it work in Query Analyzer.
> TIA.
>

osql vs Query Analyzer

We have a script with code like this
use master
go
-- do some stuff here
if exists (select name from sysdatabases where name = 'db_name')
begin
use db_name
-- do some stuff
exec storedproc
end
this works fine with Query Analyzer.
With OSQL it creates problem in the line exec storedproc. It says that
the stored procedure is not found.
we call osql as follows
osql -S servername -U username -P Password -i sqlfilename
now if we add the database name to osql
osql -S servername -U username -P Password -i sqlfilename -d db_name
it works fine.
Why should it matter. After all we are using USE statement inside the
script correctly.
How does it work in Query Analyzer.
TIA.That should work. Can you post code which we can run that displays this?
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Data Cruncher" <dcruncher4@.netscape.net> wrote in message
news:1120679914.292796.77430@.g44g2000cwa.googlegroups.com...
> We have a script with code like this
> use master
> go
> -- do some stuff here
> if exists (select name from sysdatabases where name = 'db_name')
> begin
> use db_name
> -- do some stuff
> exec storedproc
> end
> this works fine with Query Analyzer.
> With OSQL it creates problem in the line exec storedproc. It says that
> the stored procedure is not found.
> we call osql as follows
> osql -S servername -U username -P Password -i sqlfilename
> now if we add the database name to osql
>
> osql -S servername -U username -P Password -i sqlfilename -d db_name
> it works fine.
> Why should it matter. After all we are using USE statement inside the
> script correctly.
> How does it work in Query Analyzer.
> TIA.
>|||Hi
You may want to use three part naming for the procedure call.
John
"Data Cruncher" wrote:

> We have a script with code like this
> use master
> go
> -- do some stuff here
> if exists (select name from sysdatabases where name = 'db_name')
> begin
> use db_name
> -- do some stuff
> exec storedproc
> end
> this works fine with Query Analyzer.
> With OSQL it creates problem in the line exec storedproc. It says that
> the stored procedure is not found.
> we call osql as follows
> osql -S servername -U username -P Password -i sqlfilename
> now if we add the database name to osql
>
> osql -S servername -U username -P Password -i sqlfilename -d db_name
> it works fine.
> Why should it matter. After all we are using USE statement inside the
> script correctly.
> How does it work in Query Analyzer.
> TIA.
>

osql vs Query Analyzer

We have a script with code like this
use master
go
-- do some stuff here
if exists (select name from sysdatabases where name = 'db_name')
begin
use db_name
-- do some stuff
exec storedproc
end
this works fine with Query Analyzer.
With OSQL it creates problem in the line exec storedproc. It says that
the stored procedure is not found.
we call osql as follows
osql -S servername -U username -P Password -i sqlfilename
now if we add the database name to osql
osql -S servername -U username -P Password -i sqlfilename -d db_name
it works fine.
Why should it matter. After all we are using USE statement inside the
script correctly.
How does it work in Query Analyzer.
TIA.That should work. Can you post code which we can run that displays this?
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Data Cruncher" <dcruncher4@.netscape.net> wrote in message
news:1120679914.292796.77430@.g44g2000cwa.googlegroups.com...
> We have a script with code like this
> use master
> go
> -- do some stuff here
> if exists (select name from sysdatabases where name = 'db_name')
> begin
> use db_name
> -- do some stuff
> exec storedproc
> end
> this works fine with Query Analyzer.
> With OSQL it creates problem in the line exec storedproc. It says that
> the stored procedure is not found.
> we call osql as follows
> osql -S servername -U username -P Password -i sqlfilename
> now if we add the database name to osql
>
> osql -S servername -U username -P Password -i sqlfilename -d db_name
> it works fine.
> Why should it matter. After all we are using USE statement inside the
> script correctly.
> How does it work in Query Analyzer.
> TIA.
>|||Hi
You may want to use three part naming for the procedure call.
John
"Data Cruncher" wrote:
> We have a script with code like this
> use master
> go
> -- do some stuff here
> if exists (select name from sysdatabases where name = 'db_name')
> begin
> use db_name
> -- do some stuff
> exec storedproc
> end
> this works fine with Query Analyzer.
> With OSQL it creates problem in the line exec storedproc. It says that
> the stored procedure is not found.
> we call osql as follows
> osql -S servername -U username -P Password -i sqlfilename
> now if we add the database name to osql
>
> osql -S servername -U username -P Password -i sqlfilename -d db_name
> it works fine.
> Why should it matter. After all we are using USE statement inside the
> script correctly.
> How does it work in Query Analyzer.
> TIA.
>

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 versus stored procedural using in a web service

I have many problems with the stored procedural used at web service (and
this′s used by aspx page) because i get a timeout expired or this stored
procedural is very very very slowly (more than 30 minutes). Although if i use
the console and osql this stored procedural runs very very quickly (some
seconds).
Can i do somethings?
Regards, and thank very much,
Hello,
Perheaps you can try with SET FORCEPLAN
to be sure that sql server will take the correct plan
Marc Allard
Allcomp
"fravelgueAThotmailDOTcom"
<fravelgueAThotmailDOTcom@.discussions.microsoft.co m> a crit dans le message
de news: E02F7AAB-7EAE-4CA7-80B1-5A88FB2A85EF@.microsoft.com...
>I have many problems with the stored procedural used at web service (and
> thiss used by aspx page) because i get a timeout expired or this stored
> procedural is very very very slowly (more than 30 minutes). Although if i
> use
> the console and osql this stored procedural runs very very quickly (some
> seconds).
> Can i do somethings?
> Regards, and thank very much,
|||hi,
"Allcomp" <fa097770@.nospam.skynet.be> ha scritto nel messaggio
news:uaPZusetEHA.2300@.TK2MSFTNGP09.phx.gbl
> Hello,
> Perheaps you can try with SET FORCEPLAN
> to be sure that sql server will take the correct plan
SET FORCEPLAN will instuct the query optimizer to execute the join
condition(s) in the (manual) order they are presented by the developer, and
I'd be very carefull in it's use...
as oSql.exe executes the very same query in short time, I'd rather think the
problem should be bound to the web service it self or elsewhere in the
connection...
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
DbaMgr2k ver 0.9.1 - DbaMgr ver 0.55.1
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply
|||"Andrea Montanari" wrote:

> hi,
> "Allcomp" <fa097770@.nospam.skynet.be> ha scritto nel messaggio
> news:uaPZusetEHA.2300@.TK2MSFTNGP09.phx.gbl
> SET FORCEPLAN will instuct the query optimizer to execute the join
> condition(s) in the (manual) order they are presented by the developer, and
> I'd be very carefull in it's use...
> as oSql.exe executes the very same query in short time, I'd rather think the
> problem should be bound to the web service it self or elsewhere in the
> connection...
Can you help me more?
I have changed timeout of web.config and and i set the connect timeout,
but i don′t know how i can do it

> --
> Andrea Montanari (Microsoft MVP - SQL Server)
> http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
> DbaMgr2k ver 0.9.1 - DbaMgr ver 0.55.1
> (my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
> interface)
> -- remove DMO to reply
>
|||hi,
"fravelgueAThotmailDOTcom"
> Can you help me more?
> I have changed timeout of web.config and and i set the connect
> timeout, but i don′t know how i can do it
actually not... I'm very bad on web tihgs =;-D
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
DbaMgr2k ver 0.9.1 - DbaMgr ver 0.55.1
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply

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