I have a task of printing a set of addresses on a postcard on both sides. On the front the owner address will print centered, and on the back the parcel number, address, along with other data.
Four postcards are per sheet of paper. I know how to do one sided printing for postcards, my challenge is now that I have to do both sides. So I think that first, I need to align the data so what prints on the back, corresponds to what prints on the front.
I think that in order to be able to print both sides using SSRS I need to change how the records are retrieved.
Each record has 6 columns. I need to print 4 addresses per page (both sides when printing)
My data as it looks currently:
ParcelNumber OwnerName OwnerAddress Owner_City_State_Zip ParcelAddress parcel_city_state_zip
70918302278 Smith, John 15 Dimondi Ct Dover, DE, 19901 15 White Oak St Laurel, DE, 19956
70918403133 Perez, Victor 8619 S Wolcott Ave Chicago, IL, 60620 6634 W 64th Pl Chicago, IL, 60638
70918404058 Flying, Lotus 5527 E Hazel Mountain Rd Cleveland, VA, 24225 1925 Freedom Ln Falls Church, VA, 22043
70919107370 Pastorius, Jaco 1549 Highland Dr Lake Geneva, WI, 53147 415 S Wells St Lake Geneva, WI, 53147
70823107036 Bocelli, Andrea 1310 Fillmore St San Francisco, CA, 94115 1099 Fillmore St #4R San Francisco, CA, 94115
70918221072 Ttracks, Shaun 516 Manford Rd SW Atlanta, GA, 30310 480 Riverside Dr NW Atlanta, GA, 30328
70919110092 Little, John 242 W Hudson St Long Beach, NY, 11561 38 Vincent St Rockville Centre, NY, 11570
I was thinking that one way to make this work would be to insert 4 records into a single row, so that the output looks like this (sorry for the length):
ID Parcel1_1 Owner_1 OwnerAddress_1 OwnerCityStateZip_1 ParcelAddress_1 ParcelCityStateZip_1 Parcel1_2 Owner_2 OwnerAddress_2 OwnerCityStateZip_2 ParcelAddress_2 ParcelCityStateZip_2 Parcel1_3 Owner_3 OwnerAddress_3 OwnerCityStateZip_3 ParcelAddress_3 ParcelCityStateZip_3 Parcel1_4 Owner_4 OwnerAddress_4 OwnerCityStateZip_4 ParcelAddress_4 ParcelCityStateZip_4
1 70918302278 Smith, John 15 Dimondi Ct Dover, DE, 19901 15 White Oak St Laurel, DE, 19956 70918403133 Perez, Victor 8619 S Wolcott Ave Chicago, IL, 60620 6634 W 64th Pl Chicago, IL, 60638 70918404058 Flying, Lotus 5527 E Hazel Mountain Rd Cleveland, VA, 24225 1925 Freedom Ln Falls Church, VA, 22043 70919107370 Pastorius, Jaco 1549 Highland Dr Lake Geneva, WI, 53147 415 S Wells St Lake Geneva, WI, 53147
2 70823107036 Bocelli, Andrea 1310 Fillmore St San Francisco, CA, 94115 1099 Fillmore St #4R San Francisco, CA, 94115 70918221072 Tracks, Shaun 516 Manford Rd SW Atlanta, GA, 30310 480 Riverside Dr NW Atlanta, GA, 30328 70919110092 Little, John 242 W Hudson St Long Beach, NY, 11561 38 Vincent St Rockville Centre, NY, 11570 70918214126 Zidane, Zinedine 724 Hill Ave Pittsburgh, PA, 15221 711 Copeland St Pittsburgh, PA, 15232
and so on...
The table would look something like this:
DECLARE @FOUR_INTO_ONE AS TABLE
( ID_NUM INT IDENTITY(1,1)
, PARCEL_1 VARCHAR(20)
, OWNERNAME_1 VARCHAR(200)
, OWNERADDRESS_1 VARCHAR(300)
, OWNERCITYSTATEZIP_1 VARCHAR(300)
, PARCELADDRESS_1 VARCHAR(300)
, PARCELCITYSTATEZIP_1 VARCHAR(300)
, PARCEL_2 VARCHAR(20)
, OWNERNAME_2 VARCHAR(200)
, OWNERADDRESS_2 VARCHAR(300)
, OWNERCITYSTATEZIP_2 VARCHAR(300)
, PARCELADDRESS_2 VARCHAR(300)
, PARCELCITYSTATEZIP_2 VARCHAR(300)
, PARCEL_3 VARCHAR(20)
, OWNERNAME_3 VARCHAR(200)
, OWNERADDRESS_3 VARCHAR(300)
, OWNERCITYSTATEZIP_3 VARCHAR(300)
, PARCELADDRESS_3 VARCHAR(300)
, PARCELCITYSTATEZIP_3 VARCHAR(300)
, PARCEL_4 VARCHAR(20)
, OWNERNAME_4 VARCHAR(200)
, OWNERADDRESS_4 VARCHAR(300)
, OWNERCITYSTATEZIP_4 VARCHAR(300)
, PARCELADDRESS_4 VARCHAR(300)
, PARCELCITYSTATEZIP_4 VARCHAR(300))
I think this could potentially work since I would have more control as to how and where to place the values of each record page 1 and page 2.
I am not sure how to complete this using SQL, is this where a CURSOR is used? how many loops are needed, is there a simple way to manipulate the data so the out put looks like the one I need?
EDIT: I tried to follow an example that uses STUFF in this question
SELECT
Parcel =
STUFF((
SELECT [ParcelNumber]
FROM [dbo].[BI_RPEC]
WHERE [ParcelNumber] = t.[ParcelNumber]
FOR XML PATH(''), TYPE
).value('text()[1]','NVARCHAR(MAX)'), 1, 1, N'')
FROM [dbo].[BI_RPEC] t
WHERE
t.ParcelNumber IN ('070823107036','070919107370','070919110092','070918404058','070918403133','070918302278','070918221072', '070918214126')
But is retrieving only NULLS.