[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 342
  • Last Modified:

How to use SQL formula in table design?

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
2326ac
Asked:
2326ac
  • 3
  • 2
1 Solution
 
Aneesh RetnakaranDatabase AdministratorCommented:
CREATE TABLE [tablename] (
    [fname] [varchar] (50)  ,
    [lname] [varchar] (50)  ,
    [name] AS (isnull(([fname] + ' '),'') + isnull([lname],''))
) ON [PRIMARY]
GO


0
 
2326acAuthor Commented:
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
 
imran_fastCommented:
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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
Aneesh RetnakaranDatabase AdministratorCommented:
I think You should have split the points
:(
0
 
2326acAuthor Commented:
Sorry aneeshattingal quite new to this and did not think about that.  I will think more carefully next time
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now