I'm using a table to store global variables. To be general, I store
the variable value as as a varbinary(512) and the type:
CREATE TABLE tblGlobals (
[Name] varchar(32) NOT NULL ,
[XType] tinyint NOT NULL , -- SQL Server XType,
as defined in the systypes table
Value varbinary(512) NOT NULL ,
Hints varchar(32) NULL -- Optional code
that gives hints on how to interpret the value (eg, CSV for comma-
seperated-values)
) ON [PRIMARY]
GO
I will use these variables in where clauses to compare to clustered
primary keys on other tables. For example:
-- BEGIN EXAMPLE ------------------------------------------
select * from SomeTable s
-- END EXAMPLE ------------------------------------------
I want to be sure that the value from tblGlobals is used directly to
access SomeTable's index tree. Since only a reinterpret cast is needed,
this shouldn't be a problem. However, I can't find any documentation
that specifies how SQL Server will handle this. I'm afraid it might
decide to do a table scan and cast and compare at each record, ignoring
the index at great cost.
BTW, I don't know ahead of time which values are used with which
tables. That association is looked up in another table (and hard-coded
in some places).
Any ideas? Are there other ways to implement a table for storing global
variables that would be more efficient?
Thanks for your help and advice.
-Ben Blair
Sent via Deja.com http://www.deja.com/
Before you buy.