Wednesday, March 28, 2012

Job step + linked server help

I have a job step that executes a lot of stored procs against linked servers
such as
exec server1.db.dbo.abc
exec server2.db.dbo.abc
exec server3.db.dbo.abc
exec server4.db.dbo.abc
I do not wish to create multiple job steps but would like to know
programatically how i can run all those statements even if say linked server
server2 is unavailable. Currently if server2 is unavailable, it just exits
out. I would like for it to proceed and execute the last 2 stored procs for
server3 and server4TSQL jobsteps will exit if you get errors. You would have to talk to the person who wrote agent and
get a new compile to change that.
One alternative is to use a CMDExec jobstep and OSQL.EXE instead.
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as ugroup=microsoft.public.sqlserver
"Hassan" <fatima_ja@.hotmail.com> wrote in message news:%23WcbEJhkDHA.2328@.TK2MSFTNGP10.phx.gbl...
> I have a job step that executes a lot of stored procs against linked servers
> such as
> exec server1.db.dbo.abc
> exec server2.db.dbo.abc
> exec server3.db.dbo.abc
> exec server4.db.dbo.abc
> I do not wish to create multiple job steps but would like to know
> programatically how i can run all those statements even if say linked server
> server2 is unavailable. Currently if server2 is unavailable, it just exits
> out. I would like for it to proceed and execute the last 2 stored procs for
> server3 and server4
>
>|||Hassan
Check for PING to the server.
set nocount on
CREATE TABLE #t_ip (ip varchar(255))
DECLARE @.PingSql varchar(1000)
SELECT @.PingSql = 'ping ' + 00.00.0.0'
INSERT INTO #t_ip EXEC master.dbo.xp_cmdshell @.PingSql
SELECT * FROM #t_ip
IF EXISTS (SELECT TOP 2 * FROM #t_ip WHERE IP = 'Request timed out' )
BEGIN
..................
END
DROP TABLE #t_ip
"Hassan" <fatima_ja@.hotmail.com> wrote in message
news:#WcbEJhkDHA.2328@.TK2MSFTNGP10.phx.gbl...
> I have a job step that executes a lot of stored procs against linked
servers
> such as
> exec server1.db.dbo.abc
> exec server2.db.dbo.abc
> exec server3.db.dbo.abc
> exec server4.db.dbo.abc
> I do not wish to create multiple job steps but would like to know
> programatically how i can run all those statements even if say linked
server
> server2 is unavailable. Currently if server2 is unavailable, it just exits
> out. I would like for it to proceed and execute the last 2 stored procs
for
> server3 and server4
>
>

No comments:

Post a Comment