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 2008 Forums
 Analysis Server and Reporting Services (2008)
 Extract text file with header/detail rows

Author  Topic 

srose
Starting Member

3 Posts

Posted - 2013-05-27 : 11:56:37
I need to develop a query that captures a header row and its related detail records following it. Is there a way to perform this in SQL management studio? My query is returning a header record then detail record for each detail record. I need the header record, then all the corresponding detail records.

This is my result
|ClaimID|DOS|TotalAmt||ClaimID|claimline|servcode|
HDR|12345E06789A1 |2011-09-08|172|
DTL|12345E06789A1 |1 |A1234|

HDR|12345E06789A1 |2011-09-08|172|
DTL|12345E06789A1 |2 |A1235|

HDR|12345E06789A1 |2011-09-08|172|
DTL|12345E06789A1 |3 |B1235|




This is what I need
HDR|12345E06789A1 |2011-09-08|172|

DTL|12345E06789A1 |1 |A1234|

DTL|12345E06789A1 |2 |A1235|

DTL|12345E06789A1 |3 |B1235|

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-27 : 13:50:22
Sounds like presentaton issue to me. This an be easily achieved in reporting tools like SSRS. Its called Hide Duplicates in SSRS and can be accesed from textbox properties by right clicking on it.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

srose
Starting Member

3 Posts

Posted - 2013-05-27 : 14:19:39
Our IT dept doesn't give access to the reporting tools. This project was put on hold in IT due to resources, so I have been given the task to generate this extract with the limited tools I have.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-28 : 00:50:45
ok..then what are the tools you're using?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-28 : 00:54:54
just to clarify are header items coming in a row by itself?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

srose
Starting Member

3 Posts

Posted - 2013-05-28 : 09:19:02
Hi--I'm working from MS management studio. And yes, the header is coming in as a row itself, I added <CR><LF> to the query so the detail would be a row after the header. What I can't get to, is to pull that header row only once. I get a header row for each detail record.

Thanks for your help on this, much appreciated.
Go to Top of Page
   

- Advertisement -