2012年2月13日星期一

Batch File.

I am creating one batch file which move datafile and logfile into different
machine but I want to ask one question like if one command successfully
executed then I have to wait for 20 seconds and then execute the second
command .... can any one know the command which I can use in batch file...
I think there should be any wait or delay sort of command available....
Thanks in advance.
Joh wrote:
> I am creating one batch file which move datafile and logfile into
> different machine but I want to ask one question like if one command
> successfully executed then I have to wait for 20 seconds and then
> execute the second command .... can any one know the command which I
> can use in batch file... I think there should be any wait or delay
> sort of command available....
>
> Thanks in advance.
If you kick off the batch file from a stored procedure or SQL batch
file, you can use the WAITFOR DELAY command to wait for 20 seconds.
David Gugick
Imceda Software
www.imceda.com
|||I have created the Batch File in which I wrote this...
NET STOP SQLSERVERAGENT
NET STOP MsSqlserver
COPY "c:\Program Files\Microsoft SQL Server\MSSQL\Data\master.mdf"
C:\Backup\SystemDatabase
COPY "c:\Program Files\Microsoft SQL Server\MSSQL\Data\mastlog.ldf"
C:\Backup\SystemDatabase
COPY "c:\Program Files\Microsoft SQL Server\MSSQL\Data\msdbdata.mdf"
C:\Backup\SystemDatabase
COPY "c:\Program Files\Microsoft SQL Server\MSSQL\Data\msdblog.ldf"
C:\Backup\SystemDatabase
NET START SQLSERVERAGENT
NET START MSSQLSERVER
Now I want to wait after first copy so what I have to write after that?
Thanks in advance.
"David Gugick" <davidg-nospam@.imceda.com> wrote in message
news:#spQKiNVFHA.1200@.TK2MSFTNGP14.phx.gbl...
> Joh wrote:
> If you kick off the batch file from a stored procedure or SQL batch
> file, you can use the WAITFOR DELAY command to wait for 20 seconds.
> --
> David Gugick
> Imceda Software
> www.imceda.com
>
|||Joh wrote:
> I have created the Batch File in which I wrote this...
> NET STOP SQLSERVERAGENT
> NET STOP MsSqlserver
> COPY "c:\Program Files\Microsoft SQL Server\MSSQL\Data\master.mdf"
> C:\Backup\SystemDatabase
> COPY "c:\Program Files\Microsoft SQL Server\MSSQL\Data\mastlog.ldf"
> C:\Backup\SystemDatabase
> COPY "c:\Program Files\Microsoft SQL Server\MSSQL\Data\msdbdata.mdf"
> C:\Backup\SystemDatabase
> COPY "c:\Program Files\Microsoft SQL Server\MSSQL\Data\msdblog.ldf"
> C:\Backup\SystemDatabase
> NET START SQLSERVERAGENT
> NET START MSSQLSERVER
> Now I want to wait after first copy so what I have to write after
> that?
>
This is not a DOS newsgroup, and what I remember from those days is
somewhat limited. My suggestion was if you were using a stored procedure
to kick off the batch files, you could delay them using the waitfor
command. You would need to use xp_cmdshell to kick off the first batch
file, wait, then kick off the second, all from a stored procedure.
Why do you need to wait after the first copy?
David Gugick
Imceda Software
www.imceda.com
|||How can you start the SQL Service through SQL Stored procedure and through
XP_CMDSHELL .... ?
"David Gugick" <davidg-nospam@.imceda.com> wrote in message
news:uI5jN6WVFHA.3044@.TK2MSFTNGP10.phx.gbl...
> Joh wrote:
> This is not a DOS newsgroup, and what I remember from those days is
> somewhat limited. My suggestion was if you were using a stored procedure
> to kick off the batch files, you could delay them using the waitfor
> command. You would need to use xp_cmdshell to kick off the first batch
> file, wait, then kick off the second, all from a stored procedure.
> Why do you need to wait after the first copy?
>
> --
> David Gugick
> Imceda Software
> www.imceda.com
>
|||Joh wrote:
> How can you start the SQL Service through SQL Stored procedure and
> through XP_CMDSHELL .... ?
>
You can't. I only suggested it before I actually knew what you were
doing. You need to start SQL Server outside a stored procedure, for
obvious reasons.
David Gugick
Imceda Software
www.imceda.com

没有评论:

发表评论