all groups > sql server mseq > july 2003 >
You're in the

sql server mseq

group:

default value for a column



default value for a column GS
7/17/2003 5:46:46 AM
sql server mseq: I have a table with 5 million records. The table has two
columns - firstname and lastname.

During a design change, i am adding a new column say
FullName. I dont prefer to update the entire table using a
SQL query.

Instead, is there a simple way of defaulting values in the
column as sum of values in two other columns.

Re: default value for a column lindawie
7/17/2003 6:12:38 AM
GS,

[quoted text, click to view]

No, a defualt cannot reference another column. From Books Online:

"... an expression that contains only constant values (it cannot
include the names of any columns or other database objects). Any
constant, built-in function, or mathematical expression can be
used."

However, you can use a computed column in this case. This has the
advantage that the values are only stored in one place. You could
also create a view with the computed values.


use pubs
go
alter table authors add fullname as au_fname + ' ' + au_lname
go
exec sp_help authors
go
alter table authors drop column fullname


Linda
AddThis Social Bookmark Button