tags:

views:

18

answers:

2

I Have a View in SQL Server, in one column ( data type int64) it returns Null value! But I want to display Zero in it. How Can I define a default Value for Column in View?

+1  A: 

use isNull may resolve your issue like as velow

CREATE VIEW  dbo.MyView
AS 
SELECT col1, col2, isnull(numriccal3 ,0)
FROM mytable
Pranay Rana
It worked too, thanks a lot.
baran
it works than at least do up vote
Pranay Rana
I did up vote on his behalf :)
Diego
+1  A: 

You can use ISNULL, or better, COALESCE to return a value instead of a null.

SELECT COALESCE(FieldName, 0) AS FieldName
FROM Table
Diego
Thank you so much, it worked.
baran
same from my side +1 for using COALESCE
Pranay Rana