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 338681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:27:07+00:00 2026-05-12T10:27:07+00:00

I have the following tables in SQL Server 2005 ReceiptPoint: ID (PK), Name GasIndexLocation:

  • 0

I have the following tables in SQL Server 2005

ReceiptPoint: ID (PK), Name  
GasIndexLocation: Location (PK)  
ReceiptPointIndexLocation: ReceiptPointId (FK), IndexLocation (FK), StartDate, EndDate  

On any given day, a ReceiptPoint can be mapped to 1 or more IndexLocations. I need to be able to, for a given day, see what IndexLocations are being compared against. For a ReceiptPoint with multiple IndexLocations, it should show up as some kind of delimited list (for displaying to a user).

I have two problems with this.
1) ReceiptPointIndexLocation has no primary key, currently. Is the best way to handle this to just add a incrementing index field on to the table?

2) How can I get the list of IndexLocations used on a given day? From what I can tell, it would require using a non-existent string concatenation aggregate function.

Is there a totally different way I should go about organizing my data? This is still in the development stage, so I’m open to changing it.

  • 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-12T10:27:08+00:00Added an answer on May 12, 2026 at 10:27 am

    1) The primary key for ReceiptPointIndexLocation should be all four columns. However, this wouldn’t stop entries with overlapping dates for the same location and receipt. There’s no need for an identity column when you can identify rows with a composite key.

    2) SQL:

     SELECT (SELECT t.indexlocation + ','
       FROM RECEIPTPOINTINDEXLOCATION t
      WHERE t.startdate >= @start
        AND t.enddate <= @end
    FOR XML PATH(''))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following table variable in SQL Server 2005: DECLARE @results TABLE (id
I have a following scenario in my SQL Server 2005 database. zipcodes table has
i have the following tables in sql server: photoalbumsTable: album_ID album_caption albumtagmap id album_id
I have a SQL Server 2005 database with several tables. One of the tables
I have a table (SQL Server 2005) with the following columns: State: - StateId
I have following query in sql server 2005 with a table select t1.id, CONVERT(VARCHAR,t1.dt,103)
I have a table in SQL Server 2005 with the following properties: Users (UserID,
SQL Server 2005 I have a table containing the following: - [order_id] [index_1] 600020001
I am using SQL Server 2005. I have three tables - Users, Groups, and
I have the following very large table in SQL Server 2005: create table Blah

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.