Skip to main content
1 of 3
Solomon Rutzky
  • 69.5k
  • 8
  • 155
  • 300

Views do not have datatypes; they reference columns in tables that do have datatypes. You can do an explicit CONVERT() in a View, but just like any query, it will return the underlying type.

And I am not saying that one should do the following, but it is possible to use a DDL Trigger to trap CREATE TABLE statements (which is really after the event) and then scan the DDL submitted an if anything undesired was used, issue the appropriate ALTER TABLE statement. Just keep in mind that the CREATE TABLE statement might include constraints and indexes which might require being dropped in order to issue the ALTER TABLE, and then obviously re-added afterwards. So, this isn't exactly "simple". But it is at least possible and hence why I am mentioning it here because even if this specific scenario isn't advisable, the concept is at least transferable to other scenarios.

Solomon Rutzky
  • 69.5k
  • 8
  • 155
  • 300