February 8, 2005 at 7:06 am
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!
February 8, 2005 at 8:32 am
What do you mean by online an ok?? what problems are you expecting from this table (database).
February 8, 2005 at 8:44 am
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.
February 8, 2005 at 8:55 am
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.
February 8, 2005 at 8:58 am
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.
February 8, 2005 at 9:06 am
thanks for the help. I will try both cases. Both seem like they will do the trick. I appreciate the help.
February 8, 2005 at 9:09 am
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