5

Is it possible to create a computed column in a Visual Studio 2012 Database Project? There is a property called 'Computed column specification -> formula' but it is greyed out and it is not possible to enter a value in it.

Edit The computed column is also greyed out in VS 2013

1
  • 1
    Have you tried adding it in the "SQL" portion of the window? I know I have computed columns in my projects, but haven't tried to add them through the GUI. Oct 20, 2014 at 14:39

1 Answer 1

7

You can add a computed column in the T-SQL pane. For example (field FullName below):

CREATE TABLE [dbo].[Person] (
    [FirstName] VARCHAR(50) NOT NULL,
    [LastName] VARCHAR(50) NOT NULL,
    [FullName] AS ([FirstName] + ' ' + [LastName])
);

Once the column is defined in T-SQL, the "Formula" option in the properties will become editable. An option for "Is Persisted" will also appear.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.