As we all know, an open connection to database server might drop for a reason or another whenever. And a dead connection is one of the reasons that our command against database server might not succeed – instead we’ll get an exception. I mean, you can’t know in advance if the command will succeed and connection will hold for the lifetime of the execution. It turns out that all who believed the above were wrong.
You can actually predict the success of command execution. Meet ping pong test:
Dim WithEvents Pong as New Ping() Pong.Send(IPAddress) Private Sub Pong_PingCompleted(ByVal sender As Object, ByVal e As _ PingCompletedEventArgs) Handles Pong.PingCompleted If e.Reply.Status <> IPStatus.Success Then GiveUP() ElseIf e.Reply.RoundtripTime > 750 Then TryAgainLater() End If End Sub
The test above is suggested from a guy in ado.net/vb.net newsgroups. He asserts that based on the ping pong success one can predict whether connection to the database server is good, database server is up and running, will execute our command connection and will hold to the end of our command execution.
If one can extrapolate all that knowledge from a simple ping, perhaps there is even more knowledge in i.e. tracert? Is it possible to extrapolate everything (including future and past) from these simple utilities? Who knows.
Read more in “Checking for table existence” thread.
Disclaimer: This post is not serious. It is just reaction to at least funny and at worst dangerous claims (if one takes them as granted) in the newsgroups. The ping pong test just lets you know that server (not database server) is responding to ping command. Nothing else.
noone in that thread ever heard of
select * from information_schema.tables where table_name = ‘yourTableName’
?
Sure, even I suggested this approach (in general terms) as way to go. Note that this isn’t just about SQL server, but rather database in general.
true.
afaik all db’s have some kind of metadata you can chek for table existance.
but it’s a very funny and entertaining thread :))
Must be one of them brain doners. I hope he/she is replying from home, and not currently employed in IT (or anywhere else for that matter).
Idiots are like death and taxes, a sad part of life.