Problem solve Get help with specific problems with your technologies, process and projects.

Creating a view that forces a type definition on numeric fields

I want to create a view that forces a type definition on numeric fields. For example, I would like to create a view that reads off two tables, comprising of numeric fields such as sales value, sales volume etc. and non-numeric fields such as company name, contact person, address etc. I want to enforce the rule that the sales value field is of type integer or number and don't want it to go the default route. Is there any way I can explicitly state this in the view SQL syntax? The problem I am facing is that the application that is accessing the view treats the numeric fields as characters (when I define the view in the traditional manner, without giving any type definition), and so I want to enforce the type of the field in the view.

A view is simply a name for a query stored in SQL Server. You can not do something like this. The application that you are using has to be fixed, because the view will pass the data back out with the data type definitions of the underlying columns from the table. If they are all characters to the app, then the application has a bug that needs to be fixed.


For More Information

Dig Deeper on Microsoft SQL Server Installation

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.