connectivity

  • I have a set of sql select statements which I am running on one centralised server. First it checks for server connection and then if an object exists on a database from that server. next step does another select from a different server and so on. If I dont get connectivity to first server is there a way I could return some flag/error and skip it and carry on with the next steps. Does anyone have any suggestion how to go ahead with this? any help will be greatly appreciated.

    TIA

  • Or does anyone have a script that connects thru all servers (also the once not registered in EM)?

    TIA

  • You can either use ping servername or use OSQL -L for accomplishing that.

    Smth like that:

         create table #t (Pingoutput varchar(255) null)

         Declare  @cmdM varchar(30)

         Declare @servername varchar(80)

         Set @servername='YourServer'

         Set @cmdM='ping ' + @servername

         INSERT INTO #t EXEC master.dbo.xp_cmdshell @cmdM

         Select * from #t   

         WHERE Pingoutput LIKE '%timed out%'

                OR Pingoutput LIKE '%host unreachable%'

                OR Pingoutput LIKE '%Unknown host%'

         Drop table #t

    If you have a list of servers, you can while loop around the above code.

     

     

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply