Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Master-Detail Relationship in RecordSet

Author  Topic 

SQLSeeker
Starting Member

15 Posts

Posted - 2010-04-16 : 07:17:23
Hi,

I have two tables say City(Master) and Location(Detail). I want to populate record set which display first row from City and then all locations.
The View has to like this:
1 City1
2 location11
3 location12
4 City2
5 location21
6 location22

Is it Possible through SQL Statement

Thanks


webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-04-16 : 07:19:38
Do that in your fron end.
That is not what T-Sql is made for.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-04-16 : 07:41:49
You *can* do it using ranking functions like ROW_NUMBER()

But as Webfred said do it in the application layer -- this is trivially easy to do in an application by just horizontal parsing of the result sets.


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-04-16 : 08:45:56
If you are using ASP.Net you can refer to this article on displaying Master,Detail relationship.

http://www.progtalk.com/viewarticle.aspx?articleid=16

PBUH
Go to Top of Page

SQLSeeker
Starting Member

15 Posts

Posted - 2010-04-19 : 01:55:22
Hi Idera,

Thanks for your help, Its really helpful.

Thanks
Go to Top of Page
   

- Advertisement -