Returning the status of a table in SQL Server 2000

  • I am looking into writing a VBA script that checks the status of a table in SQL Server, i.e. I need to know if the table I am sending alarm and event information too is online and ok.  I know I can simply check the connection, but is there a way to get feedback from the table itself to see that it is online and ok?

     

    Thx!

  • What do you mean by online an ok?? what problems are you expecting from this table (database).

  • in other words can i run a query against the table, if needed.  Mainly the only thing that would be of concern would be if SQL Server is not running.  In that case I can just check the connection to SQL.  I was wanting to make sure also that the table exists and that inserts/updates/select statements can be executed against the table.

  • You could run something like this...

    IF EXISTS (Select * from dbo.SysObjects where Name = '#your table name#' and XType = 'U')

    SELECT 1

    ELSE

    SELECT 0

    This would return one if the table exists. However I would further assume that if the table exists then you can do any transaction you need as long as you have permissions to do so.

  • How about:

    Select * From YourTable Where 0 = 1

    You'll either get a zero size resultset in very fast time, or an error if there's a problem accessing the table.

  • thanks for the help.  I will try both cases.  Both seem like they will do the trick.  I appreciate the help.

  • Yes they will both work.. it's just a matter of preferrence, I preffer to avoid errors when I can. Especially in vb6 where err handling is a big pain in the @ss.

Viewing 7 posts - 1 through 6 (of 6 total)

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