Bob Avallone
Bob Avallone

Reputation: 379

How to define a new field in a view in sql server

I am creating a view based on another table but there are also new fields in the view that are not in the table, The person who did the view did it like this "Null as Newfield". I want the field to be set to Null but I want the field to be Varchar(1) instead I got a int field. I'm not sure of the exact syntax to make this happen. I cannot find an example.

Thanks in advance

Upvotes: 2

Views: 138

Answers (1)

Jakub Kania
Jakub Kania

Reputation: 16487

What you're looking for is Cast() (CAST and CONVERT (Transact-SQL)).

Cast(NULL AS  Varchar(1)) AS Newfield

Upvotes: 3

Related Questions