Solved

How to use SQL formula in table design?

Posted on 2006-11-15
6
284 Views
Last Modified: 2012-05-05
I have two fields in my table - firstname and surname - I would like to have a field named whole name and the value of the previous fields I mentioned put into this as a default value.

How can I go about doing this?
0
Comment
Question by:2326ac
  • 3
  • 2
6 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17948612
CREATE TABLE [tablename] (
    [fname] [varchar] (50)  ,
    [lname] [varchar] (50)  ,
    [name] AS (isnull(([fname] + ' '),'') + isnull([lname],''))
) ON [PRIMARY]
GO


0
 

Author Comment

by:2326ac
ID: 17950132
I am new to SQL to server can this be done within the table design using the formula field, sorry im used to MS Access
0
 
LVL 28

Accepted Solution

by:
imran_fast earned 500 total points
ID: 17971144
Yes it can be go to the table go to the design
add a new column name and put
isnull([fname] + ' ') + isnull([lname],'')
in the formula.
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17974417
I think You should have split the points
:(
0
 

Author Comment

by:2326ac
ID: 17978973
Sorry aneeshattingal quite new to this and did not think about that.  I will think more carefully next time
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17984794
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

827 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question