View Single Post

   
  #5 (permalink)  
Old 02-29-2008, 04:55 AM
Erland Sommarskog
 
Posts: n/a
Default Re: Is it wrong to allow user initiated DDL commands to facilitate an extensible schema

Mischa Sandberg (mischa_sandberg@telus.net) writes:
> It also gives you a way to enforce TYPES on the values,
> which is another real issue with attribute/value format.


Apparently in Karen's case, the attributes were numeric, so maybe it's
issue this time.

In the general case where attributes are of mixed types, you can use the
the sql_variant datatype, and supplement with a column which defines
the datatype. Then you have a constraint which goes like this:

sql_variant_property(value, 'Basetype') =
CASE typeofdata
WHEN 'B' THEN bit
WHEN 'D' THEN datetime
...
END

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Reply With Quote