[dba-SQLServer] John Colby's problem

JWColby jwcolby at colbyconsulting.com
Sat Feb 17 13:45:42 CST 2007


I just discovered SQL_Variant data type.  I haven't tried using it yet, but
it does seem to solve the "can be any data type" issue for my data store
issue.  The tables now look like:

tblPeople
PE_ID
PE_Fname
.
.

tblSurvey
SV_ID			'Survey ID
SV_Name		'Survey Name

tblSurveyField
SVFLD_ID		'Survey Field ID
SVFLD_IDSV		'Survey ID
SVFLD_Name		'Survey Name
SVFLD_DataType	'Survey Data Type

tblSurveyData
SVDAT_ID		'Survey Data ID
SVDAT_IDSVFLD	'Survey Field ID
SVDAT_IDPE		'Person ID
SVDAT_Data		Type SQL_Variant

Thus the process that normalizes the data "discovers" the data type at the
field level and stores the data type in the field table.  The data is stored
in the data field, apparently converted to the correct type (from the text
that I receive in a survey flat file).  On the way back out, the
SVFLD_DataType is used to cast the data back to the correct type for
compares etc.

Thoughts on the matter?

John W. Colby
Colby Consulting
www.ColbyConsulting.com




More information about the dba-SQLServer mailing list