Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The original form has denormalized data, as there are many phone numbers in one cell. Your database has a good normalized structure. This is what is making things tricky. The easiest way to get what you want is to denormalize the data before sending it to reporting services. This means getting all phone numbers for a person and putting them in a string.</p> <p>I took your script, and changed the temporary tables to permanent tables. I then added the following function to get denormalized phone data:</p> <pre><code>create function fnGetDenormPhoneFromPersonID(@personID int) returns varchar(8000) as begin declare @number varchar(8); declare @phoneType varchar(10); declare @DenormPhone varchar(8000); set @DenormPhone = ''; declare MyCursor cursor for select number, phoneType from phoneNumbers where personID = @personID; open MyCursor fetch next from MyCursor into @number, @phoneType; while @@FETCH_STATUS = 0 begin set @DenormPhone = @DenormPhone + @phoneType + ' ' + @number + ';' fetch next from MyCursor into @number, @phoneType; end close MyCursor deallocate MyCursor return @DenormPhone end </code></pre> <p>Then use the following select:</p> <pre><code> select person.personID, name, (datediff(YY, birthdate, getdate()) - case when((month(birthdate)*100 + day(birthdate)) &gt; (month(getdate())*100 + day(getdate()))) then 1 else 0 end) as age, birthdate, gender, roomnumber, dbo.fnGetDenormPhoneFromPersonID(personID) as DenormPhone from person </code></pre> <p>and put it into a standard table built by the report designer, with all fields in the details. </p> <p>I changed the expression for Denorm Phone to </p> <pre><code>=Replace(Fields!DenormPhone.Value, ";", vbCRLF) </code></pre> <p><img src="https://i.stack.imgur.com/dhX0u.png" alt="Report Screenshot"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload