SQLTeam.com | Weblogs | Forums

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


#1

hello

i have a view and i need a field that is not existed in none of my tables
i want to know if it is possible to create a new field in this view in sql?
this field is not a calculated or something else
it is not related to none of other fields in this view
can you help please?


#2

in short . . yes you can. But the value of the field must be coming from somewhere right ? So where is the value of this field coming from ?


#3

no it is just a field and then i want to import (link) this table to ms access and then enter the values manually to the form and saving them to this view


#4

don't quite understand what you are trying to achieve with the view here. .

anyway, you can do this

CREATE VIEW your_view
AS
SELECT new_field = convert(varchar(100), NULL),
              . .  . .
FROM   . . . 

the new_field will have value of NULL

the convert is to define a data type for the column new_field


#5

thank you
then how i can insert data to this field to this table


#6

you can't. Since this is not a column of a table.


#7

if you want to update a column of a table why not include that in the view ? ?


#8

You can use ALTER VIEW command to create a new field in a view.


#9

Please learn SQL. The term "field" in SQL is part of a temporal value = {YEAR, MONTH, DAY, HOUR, MINUTE, SECOND }. A field in a file is nothing like a column in SQL!

Did you ,mean a column? And yes, you can add an expression to the SELECT list of a VIEW.


#10

Please go away