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

  • Home
  • SEARCH
  • 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 697715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:11:47+00:00 2026-05-14T03:11:47+00:00

A location table record has two address id’s – mailing and business addressID that

  • 0

A location table record has two address id’s – mailing and business addressID that refer to an address table.

Thus, the address table will contain up to two records for a given addressID.

Given a location ID, I need an sproc to return all tbl_Location fields, and all tbl_Address fields in one resultset:

            LocationID INT,
            ClientID INT,
            LocationName NVARCHAR(50),
            LocationDescription NVARCHAR(50),
            MailingAddressID INT,
            BillingAddressID INT,
            MAddress1 NVARCHAR(255),
            MAddress2 NVARCHAR(255),
            MCity NVARCHAR(50),
            MState NVARCHAR(50),
            MZip NVARCHAR(10),
            MCountry CHAR(3),
            BAddress1 NVARCHAR(255),
            BAddress2 NVARCHAR(255),
            BCity NVARCHAR(50),
            BState NVARCHAR(50),
            BZip NVARCHAR(10),
            BCountry CHAR(3)

I’ve started by creating a temp table with the required fields, but am a bit stuck on how to accomplish this.

I could do sub-selects for each of the required address fields, but seems a bit messy.

I’ve already got a table-valued-function that accepts an address ID, and returns all fields for that ID, but not sure how to integrate it into my required result.

Off hand, it looks like 3 selects to create this table – 1: Location, 2: Mailing address, 3: Billing address.

What I’d like to do is just create a view and use that.

Any assistance would be helpful.

Thanks.

  • 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-14T03:11:48+00:00Added an answer on May 14, 2026 at 3:11 am

    If I understand your question correctly you want something like:

    SELECT
        L.*,
        MAddress1 = M.Address1,
        MAddress2 = M.Address2,
        MCity = M.City,
        MState = M.State,
        MZip = M.Zip,
        MCountry = M.Country
        BAddress1 = B.Address1,
        BAddress2 = B.Address2,
        BCity = B.City,
        BState = B.State,
        BZip = B.Zip,
        BCountry = B.Country
    FROM
        tbl_Location L
        INNER JOIN tbl_Address M
            ON L.MailingAddressID = M.MailingAddressID
        INNER JOIN tbl_Address B
            ON L.BillingAddressID = B.BillingAddressID
    WHERE
        L.LocationID = @LocationID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been handed a table with about 18000 rows. Each record describes the location
I have two tables: Table 1: ID, PersonCode, Name, Table 2: ID, Table1ID, Location,
I have a table with records that has delete links. Basically I followed the
I have a model Rails model called Orders that has a type_id, location, and
I have table with 50 entries (users with such details like Name Surname Location
I m using a dropdown to display Location field of a table. I want
I have a database table named call with columns call_time, location, emergency_type and there
Does anybody know how to determine the location of a file that's in one
I have two SQL Server 2005 instances that are geographically separated. Important databases are
In a table there are like 113 columns. and there are two default records

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.