Hmmmm. Ok, it was a user error (I was querying the wrong database). On the
other point, about being wary of querying system tables in an application,
is there anything imparticular I should be wary of? The way I see it, there
are two methods of determining if any given database (1) supports my
application and (2) supports the current version of my application.
Firstly, I could just execute the "abcd_GetVersio n" stored procedure. I
will get an exception if it fails, ergo: not a database my software can use.
Once I have established abcd_GetVersion can be executed, I can just execute
it to find the database version and everyone is happy. The second way is
to query the system tables for objects I know are unique to my schema/object
set (ie. looking for a specific stored procedure).
Now the issue I have is that I'm enumerating servers in a combo box on a
form and I have a checkbox which states "only show servers hosting a
compatible database". Actually attempting to connect, run the stored
procedure and fail on exception is an amazingly slow way of doing this.
Much simpler I think, to just check the sysobjects table to see if the given
stored procedure I need is there.
So heres what I would like to do: connect to the server. If the connection
fails, then I am not a compatible server (for whatever reason). Once
connected: query something, somewhere to find out if the server hosts a
certain kind of database. Will I have enumerate the entire list of
databases and check each one individually?
"Erland Sommarskog" <es****@sommars kog.se> wrote in message
news:Xn******** **************@ 127.0.0.1...
Robin Tucker (id************ *************@r eallyidont.com) writes: I'm trying to determine with my program whether or not a given database
supports a given feature set. To do this I'm querying for certain
stored procedures in the sysobjects table and if they are present,
making the assumption the database will support the given feature. The
problem is I can't find a certain stored procedure in the sysobjects
table, even though I know it exists and can see other similar procedures
using:
select * from dbo.sysobjects order by name
Its as if all of my other stored procedures are in the sysobjects table
except this one, the one I'm specifically querying for. Are there
certain reasons why a proc won't appear in the sysobjects table? Is
this something I need to fix?
Sounds like there is some mishap with owner. Or a surprising character
somewhere. i and í are not too easy to discern.
The best way to check whether a stored procedure exists is with
IF object_id('your procedure', 'P') IS NOT NULL
While querying system tables and INFORMATION_SCH EMA is good for admin
and maintenance stuff, I think one should be wary of doing in application
code.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp