Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3441154
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:31:05+00:00 2026-05-18T08:31:05+00:00

Introduction first, question at the end. Please read carefully! I have a master-detail relation

  • 0

Introduction first, question at the end. Please read carefully!


I have a master-detail relation between two tables:

CREATE TABLE [dbo].[LookupAttributes] (
    [Id] int IDENTITY (1, 1) NOT NULL, 
    [Name] nvarchar (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL) ;
ALTER TABLE [dbo].[LookupAttributes] ADD CONSTRAINT [PK_LookupAttributes] PRIMARY KEY ([Identity]) ; 

CREATE TABLE [dbo].[Lookup] (
    [Id] int IDENTITY (1, 1) NOT NULL, 
    [LookupAttributesLink] int NOT NULL, 
    [Code] nvarchar (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, 
    [Value] nvarchar (80) COLLATE SQL_Latin1_General_CP1_CI_AS NULL) ;
ALTER TABLE [dbo].[Lookup] ADD CONSTRAINT [IX_Lookup] UNIQUE ([LookupAttributenLink], [Code]) ; 

(There are more fields and indices in both tables but these are the ones that matter…)

The project I’m working on is meant to maintain data in 50+ tables, and every week this data is exported to XML to be used by some desktop application as source data. While I wanted to make this a pretty-looking application, it just needed to be done fast, thus I use a Dynamic Data Site so the data can be maintained. It works just fine, except for this table…

As it turns out, there are 600 different lookup records that share the same code, but different attributes. The DDS displays attribute and code correctly in the list of lookup records so there never was any confusion about which lookup record someone was editing. And this has been in use for over 2 years now.


Now the problem: A new table “Lookup-Override” has been added which links to the [Id] field of the Lookup table. Each record in this new table thus displays the [Code] field, but since [Code] isn’t unique, it’s unclear which Override record belongs to which Lookup record.
To solve this, I need to display more information from the Lookup record. Since the only unique set of fields is the attribute plus code, I need to display both. But displaying [LookupAttributesLink]+[Code] isn’t an option either, since [LookupAttributesLink] is just a number.
I need the DDS to display [Attributes].[LookupAttributesLink]+[Lookup].[Code] in a single column. Question is: how?
I’ve considered adding a calculated field to the Lookup table, but I cannot get the attribute name that way.
I could create a special page to maintain this table but I don’t like that solution either, since it “breaks” the DDS principle in my opinion. I’m trying to avoid such pages.
So, any other possibilities to get the site display both attribute name and lookup code in the override table?


The most interesting solution would be by using a calculated field which could retrieve the attribute name. How to do that?


Solved it myself! See answer below, which works just fine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:31:06+00:00Added an answer on May 18, 2026 at 8:31 am

    Found it! I had to do a few things:

    CREATE FUNCTION LookupName (
      @Attr int,
      @Code nvarchar(255)
    ) RETURNS nvarchar(1000)
    AS
    BEGIN
     DECLARE @Name nvarchar(1000)
     SELECT @Name = Name
     FROM [dbo].[LookupAttributes]
     WHERE [Id]=@Attr;
     RETURN @Name + '/' + @Code;
    END
    GO
    ALTER TABLE [dbo].[lookup] ADD [Name] AS [dbo].[LookupName]([LookupAttributesLink], [Code])
    GO
    

    This will add an additional calculated field to the table which uses a function to calculate the proper name. I then had to add some metadata for the lookup table:

    [MetadataType(typeof(LookupMetadata))]
    public partial class Lookup { }
    [DisplayColumn("Name", "Name")]
    [DisplayName("Lookup")]
    public class LookupMetadata
    {
        [ScaffoldColumn(false)]
        public int Id;
        [ScaffoldColumn(false)]
        public object Name;
    }
    

    This will hide the Name column from the Lookup table itself, but it makes it visible for the Override table. (And it will be used to display the proper value.
    Done this, solved the problem! Quite easy, actually. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just read about the breadth-first search algorithm in the Introduction to Algorithms book
First a little introduction. We have an SQL Server Express 2008 database, which schema
First, a little introduction. I have to functions: static class C { static void
Introduction I have a question coming from this one: Loop calling an asynchronous function
I am teaching a course Introduction to Computer Programming to the first year math
Introduction I have been so annoyed by applications that have a startup dialog which
Introduction: Now I know this question could be very broad and it would be
Introduction We have an OpenID Provider which we created using the DotNetOpenAuth component. Everything
Introduction I have some sort of values that I might want to access several
First time using this service for a question. I hope I am not asking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.