how to return typed nulls from a view
I have multiple views fueling entity framework, and some of the views don't return all the fields as their brethren.
for EF's sake, i nee开发者_JS百科d to ensure that all views return the same signature. So in the views that have less fields, i simply add missing columns:
,Column1
,Column2
,null Column3
since Column3 is not in the table returned by the view, i simply add it to match the signature of other views that do have Column3.
My question is, how can I make Column3 typed, so that if i run sp_help MyView that column is returned as string, or int etc.. I know i could return 0 Column3 or '' Column3, but i would like to keep it null.
Just cast
the column:
, cast(null as datetime) as Column3
精彩评论