baran
baran

Reputation: 49

Define default value for columns in View

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?

Upvotes: 2

Views: 1586

Answers (2)

Diego
Diego

Reputation: 7562

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

SELECT COALESCE(FieldName, 0) AS FieldName
FROM Table

Upvotes: 1

Pranay Rana
Pranay Rana

Reputation: 176896

use isNull may resolve your issue like as velow

CREATE VIEW  dbo.MyView
AS 
SELECT col1, col2, isnull(numriccal3 ,0)
FROM mytable

Upvotes: 1

Related Questions