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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:18:27+00:00 2026-06-12T21:18:27+00:00

My colleague asked me a question regarding getting data from a SQL Server database.

  • 0

My colleague asked me a question regarding getting data from a SQL Server database.

I have a sample data set

[ID],[TOWN],[PERSON]
[1],[BELFAST],[JAMES]
[2],[NEWRY],[JOHN]
[3],[BELFAST],[SIMON]
[4],[LARNE],[ALAN]

Now from this I would like to return a SQL Dataset that returns me a different table based upon the view.

Essentially in code I could get a distinct on the town then loop sql filtering on the town. But is there a way I can do this in SQL?

Where I would get (3) views back (2 Belfast, 1 Newry and 1 Larne)

Basicly I it would return

[ID],[Town],[Person]
[1],[Belfast],[James]
[3],[Belfast],[Simon]

Then another view would return for ‘Larne’ and a Final one for Newry. Basically SQL creating views for each town it finds and then returns the records for each town.

  • 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-06-12T21:18:28+00:00Added an answer on June 12, 2026 at 9:18 pm

    Basically I have decided to Run it as a Stored Procedure to return me each item as a List. So something along the lines of this:

    Create Procedure ListTowns
    As
    declare @towns char(11)
    
    select @towns = (select distinct Town from [Towns])
    
    while @towns is not null <> 0
    begin
        select * from [YourTable] where Town = @towns
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A colleague asked me, if you have a table in SQL Server with only
I have been asked to extract info by an academic colleague from a website
I have been asked this question by a colleague that should we always include
I was asked this question today by a colleague, and couldn't find any clue
I have looked around here to see if somebody has asked this question before
A colleague asked me an interesting question today - is the C# keyword/operator is
Colleague has asked the question and we were unable to find it - on
My colleague asked me a question like license check to config file. when i
Possible Duplicate: Returning false from Equals methods without Overriding One of my colleague asked
I was configuring IPtable yesterday. My colleague just asked me this question, and I

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.