SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Analysis Server and Reporting Services (2008)
 Extract text file with header/detail rows
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

srose
Starting Member

USA
3 Posts

Posted - 05/27/2013 :  11:56:37  Show Profile  Reply with Quote
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|

Edited by - srose on 05/27/2013 12:30:02

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 05/27/2013 :  13:50:22  Show Profile  Reply with Quote
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

USA
3 Posts

Posted - 05/27/2013 :  14:19:39  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 05/28/2013 :  00:50:45  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 05/28/2013 :  00:54:54  Show Profile  Reply with Quote
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

USA
3 Posts

Posted - 05/28/2013 :  09:19:02  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.16 seconds. Powered By: Snitz Forums 2000