Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
731 views
in Technique[技术] by (71.8m points)

reporting services - Add the columns automatically in SSRS report

Currently we are having 6 columns in our database table which we are showing in the SSRS report but in future if we add 1 more column then without any manual changes on RDL it will included in the report.

Current report Example :-

Name    Address Code    City    County  Country
xyz     Lane 1  466001  Bang    dbc      Africa
abc     Lane 2  466002  Bpl     bbn      Nepal
dcb     Lane 3  466003  sbc     wad      Bhutan

Expected report without adding the column manually in SSRS.

Name    Address Code    City    County  Country DOB
xyz     Lane 1  466001  Bang    dbc     Africa  19/06/1986
abc     Lane 2  466002  Bpl     bbn     Nepal   20/06/1990
dcb     Lane 3  466003  sbc     wad     Bhutan  21/8/2000

Thanks for any help.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Please follow below steps..

Step 1. Create Proc using UNPIVOT and Property(ColunName) & Value with ID column (PKey) like

SELECT Pkey,tblPivot.Property, tblPivot.Value
 FROM (SELECT EmpNo AS Pkey, CONVERT(sql_variant,EmpNo) AS EmpNo, CONVERT(sql_variant,EName) AS EName, CONVERT(sql_variant,JOB) AS JOB, 
 CONVERT(sql_variant,Sal) AS Sal FROM EMP) EMP 
UNPIVOT (Value For Property In (EmpNo,EName, JOB, Sal)) as tblPivot

Step 2.

Create a Matrix Report using above SP with row-grouping on [Pkey] and col-grouping on [Property] and Display value ...

enter image description here

Step 3 Now you can add/remove column in SP (step 1) based on your requirement


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...