I wish to have a batch file(test.bat) that does an OSQL as below. The OSQL
statement below needs some modification as well.
OSQL -E -S%1 -Q"select @.@.servername" -oc:\xyz\%1output.txt
When i enter test.bat, i want it to prompt for servername so i can add it at
the prompt
Also i would like the prompted servername to be filled in %1 parameter in
the OSQL . Can this be done ?Hi Hassan,
This is not the right place to ask any batch file related questions.
Anyway try this ....
You can specify server name in the command propmt. If you haven't specify
the server name in the command prompt it will prompt for it.
Regards,
Suhanthan, V.
suhan@.jhc.lk
----
@.ECHO OFF
IF NOT _%1_ == __ GOTO WITHPARAM
GOTO WITHOUTPARAM
:WITHPARAM
OSQL -E -S%1 -Q"select @.@.servername" -oc:\xyz\%1output.txt
GOTO EXITTHIS
:WITHOUTPARAM
SET /P SERVER="Enter SQL server name :"
OSQL -E -S%SERVER% -Q"select @.@.servername" -oc:\xyz\%1output.txt
SET SERVER=
:EXITTHIS
----
"Hassan" <fatima_ja@.hotmail.com> wrote in message
news:O2$uiVRnDHA.1084@.tk2msftngp13.phx.gbl...
> I wish to have a batch file(test.bat) that does an OSQL as below. The OSQL
> statement below needs some modification as well.
> OSQL -E -S%1 -Q"select @.@.servername" -oc:\xyz\%1output.txt
> When i enter test.bat, i want it to prompt for servername so i can add it
at
> the prompt
> Also i would like the prompted servername to be filled in %1 parameter in
> the OSQL . Can this be done ?
>
>
2012年2月13日星期一
Batch file check database available during weekend.
Hi Everyone,
I need create the batch file to check sql server databases available during
the weekend.
I try to do run query use osql in batch file and the result write to a log
file. And check if the log file include "fail" string then email or page
someone, if not that means database is OK. Which batch command can implement
this check?
Any input much appreciates!
ChenYou can run a simple query (any simple query) accessing a table (such as
sysobjects or perhaps another smaller ) in that database.
Personally, I don't think it's a good idea to use a batch file for this
purpose because batch files are rather limited in their ability to handle
errors returned from a program. I'd use a real programming language, connect
to the SQL instance using ADO or ADO.NET, and walk through the returned erro
r
messages to verify that there is indeed a problem with accessing the databas
e.
Linchi
"Chen" wrote:
> Hi Everyone,
> I need create the batch file to check sql server databases available durin
g
> the weekend.
> I try to do run query use osql in batch file and the result write to a log
> file. And check if the log file include "fail" string then email or page
> someone, if not that means database is OK. Which batch command can impleme
nt
> this check?
> Any input much appreciates!
> Chen|||For service availability monitoring better option is to go for tools like:-
NetIQ'a Diagnostic Mangager
or
BMC Patrol
Thanks
Hari
SQL Server MVP
"Chen" wrote:
> Hi Everyone,
> I need create the batch file to check sql server databases available durin
g
> the weekend.
> I try to do run query use osql in batch file and the result write to a log
> file. And check if the log file include "fail" string then email or page
> someone, if not that means database is OK. Which batch command can impleme
nt
> this check?
> Any input much appreciates!
> Chen|||"Chen" <Chen@.discussions.microsoft.com> wrote in message
news:31D219AE-B65C-47AD-AAF2-BB80D73FBDE2@.microsoft.com...
> Hi Everyone,
> I need create the batch file to check sql server databases available
during
> the weekend.
> I try to do run query use osql in batch file and the result write to a log
> file. And check if the log file include "fail" string then email or page
> someone, if not that means database is OK. Which batch command can
implement
> this check?
We use Servers Alive product for this (and many other things.)
> Any input much appreciates!
> Chen
I need create the batch file to check sql server databases available during
the weekend.
I try to do run query use osql in batch file and the result write to a log
file. And check if the log file include "fail" string then email or page
someone, if not that means database is OK. Which batch command can implement
this check?
Any input much appreciates!
ChenYou can run a simple query (any simple query) accessing a table (such as
sysobjects or perhaps another smaller ) in that database.
Personally, I don't think it's a good idea to use a batch file for this
purpose because batch files are rather limited in their ability to handle
errors returned from a program. I'd use a real programming language, connect
to the SQL instance using ADO or ADO.NET, and walk through the returned erro
r
messages to verify that there is indeed a problem with accessing the databas
e.
Linchi
"Chen" wrote:
> Hi Everyone,
> I need create the batch file to check sql server databases available durin
g
> the weekend.
> I try to do run query use osql in batch file and the result write to a log
> file. And check if the log file include "fail" string then email or page
> someone, if not that means database is OK. Which batch command can impleme
nt
> this check?
> Any input much appreciates!
> Chen|||For service availability monitoring better option is to go for tools like:-
NetIQ'a Diagnostic Mangager
or
BMC Patrol
Thanks
Hari
SQL Server MVP
"Chen" wrote:
> Hi Everyone,
> I need create the batch file to check sql server databases available durin
g
> the weekend.
> I try to do run query use osql in batch file and the result write to a log
> file. And check if the log file include "fail" string then email or page
> someone, if not that means database is OK. Which batch command can impleme
nt
> this check?
> Any input much appreciates!
> Chen|||"Chen" <Chen@.discussions.microsoft.com> wrote in message
news:31D219AE-B65C-47AD-AAF2-BB80D73FBDE2@.microsoft.com...
> Hi Everyone,
> I need create the batch file to check sql server databases available
during
> the weekend.
> I try to do run query use osql in batch file and the result write to a log
> file. And check if the log file include "fail" string then email or page
> someone, if not that means database is OK. Which batch command can
implement
> this check?
We use Servers Alive product for this (and many other things.)
> Any input much appreciates!
> Chen
Batch file check database available during weekend.
Hi Everyone,
I need create the batch file to check sql server databases available during
the weekend.
I try to do run query use osql in batch file and the result write to a log
file. And check if the log file include "fail" string then email or page
someone, if not that means database is OK. Which batch command can implement
this check?
Any input much appreciates!
ChenYou can run a simple query (any simple query) accessing a table (such as
sysobjects or perhaps another smaller ) in that database.
Personally, I don't think it's a good idea to use a batch file for this
purpose because batch files are rather limited in their ability to handle
errors returned from a program. I'd use a real programming language, connect
to the SQL instance using ADO or ADO.NET, and walk through the returned error
messages to verify that there is indeed a problem with accessing the database.
Linchi
"Chen" wrote:
> Hi Everyone,
> I need create the batch file to check sql server databases available during
> the weekend.
> I try to do run query use osql in batch file and the result write to a log
> file. And check if the log file include "fail" string then email or page
> someone, if not that means database is OK. Which batch command can implement
> this check?
> Any input much appreciates!
> Chen|||For service availability monitoring better option is to go for tools like:-
NetIQ'a Diagnostic Mangager
or
BMC Patrol
Thanks
Hari
SQL Server MVP
"Chen" wrote:
> Hi Everyone,
> I need create the batch file to check sql server databases available during
> the weekend.
> I try to do run query use osql in batch file and the result write to a log
> file. And check if the log file include "fail" string then email or page
> someone, if not that means database is OK. Which batch command can implement
> this check?
> Any input much appreciates!
> Chen|||"Chen" <Chen@.discussions.microsoft.com> wrote in message
news:31D219AE-B65C-47AD-AAF2-BB80D73FBDE2@.microsoft.com...
> Hi Everyone,
> I need create the batch file to check sql server databases available
during
> the weekend.
> I try to do run query use osql in batch file and the result write to a log
> file. And check if the log file include "fail" string then email or page
> someone, if not that means database is OK. Which batch command can
implement
> this check?
We use Servers Alive product for this (and many other things.)
> Any input much appreciates!
> Chen
I need create the batch file to check sql server databases available during
the weekend.
I try to do run query use osql in batch file and the result write to a log
file. And check if the log file include "fail" string then email or page
someone, if not that means database is OK. Which batch command can implement
this check?
Any input much appreciates!
ChenYou can run a simple query (any simple query) accessing a table (such as
sysobjects or perhaps another smaller ) in that database.
Personally, I don't think it's a good idea to use a batch file for this
purpose because batch files are rather limited in their ability to handle
errors returned from a program. I'd use a real programming language, connect
to the SQL instance using ADO or ADO.NET, and walk through the returned error
messages to verify that there is indeed a problem with accessing the database.
Linchi
"Chen" wrote:
> Hi Everyone,
> I need create the batch file to check sql server databases available during
> the weekend.
> I try to do run query use osql in batch file and the result write to a log
> file. And check if the log file include "fail" string then email or page
> someone, if not that means database is OK. Which batch command can implement
> this check?
> Any input much appreciates!
> Chen|||For service availability monitoring better option is to go for tools like:-
NetIQ'a Diagnostic Mangager
or
BMC Patrol
Thanks
Hari
SQL Server MVP
"Chen" wrote:
> Hi Everyone,
> I need create the batch file to check sql server databases available during
> the weekend.
> I try to do run query use osql in batch file and the result write to a log
> file. And check if the log file include "fail" string then email or page
> someone, if not that means database is OK. Which batch command can implement
> this check?
> Any input much appreciates!
> Chen|||"Chen" <Chen@.discussions.microsoft.com> wrote in message
news:31D219AE-B65C-47AD-AAF2-BB80D73FBDE2@.microsoft.com...
> Hi Everyone,
> I need create the batch file to check sql server databases available
during
> the weekend.
> I try to do run query use osql in batch file and the result write to a log
> file. And check if the log file include "fail" string then email or page
> someone, if not that means database is OK. Which batch command can
implement
> this check?
We use Servers Alive product for this (and many other things.)
> Any input much appreciates!
> Chen
订阅:
博文 (Atom)