Combining Columns | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Combining Columns

Is there a way in SQL Server to create a column that is comprised of two other columns? E.g
Column1 = FirstName
Column3 = FirstandLastName
Is there some formula which will automatically add to column three when 1 and 2 have been populated?
Make it a computed column and create a function based on column1 and column2. e.g. create function dbo.ConstructFullName(@first varchar(50), @last varchar(50))
returns varchar(101)
return @first + ‘ ‘ + @last
end NB. if either @first or @last are NULL then the result should be NULL. Then just put dbo.ConstructFullName(Column1, Column2) as the function for your computed column. Dave. Ask a SQL Server Question
Being a new comer to SQL Server, how do I make it a computed colum and creat the function as you said?
Refer to the books online and this link for information. Satya SKJ
This posting is provided “AS IS” with no rights for the sake of knowledge sharing.