In SQL 2005/8 I'm looking to convert a column in select query to a NOT NULL column.
coalease()
and isnull()
, although fine functions, is not what I'm looking for. I want the select to throw an error is any of the data is NULL.
Is this possible?
[Update] Clearly the best approach would be to modify the source table, unfortunatly in this case, it's not a (cost-effective) option.
What you ask for doesn't exists.
NOT NULL is a constraint. SELECT statements do not enforce constraints. Constraints are only enforced during INSERT/UPDATE/DELETE of the data. If you need to enforce a constraint, declare the constraint on the table, via ALTER TABLE ... ADD...
If you want to return non-null data, use a null translation function like ISNULL or COALESCE.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With