Validate datatype of operands in a mathematical expression
I have to create a mathematical expression with column objec开发者_如何学Got as operands and validate the datatype of the operands. The column object represents a database column and consists of table name, column name and datatype. If the operand datatype is text
or bool
an error message should be displayed. How can this validation be done?
This is going to vary based on what database engine you are using, but for SQL Server, you could use this query to load column shema data to compare against:
SELECT COLUMN_NAME, IS_NULLABLE, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH
FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = @TABLE_NAME
精彩评论