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.
Author |
Topic |
sgandhi
Posting Yak Master
115 Posts |
Posted - 2009-04-03 : 10:07:50
|
Hi, i want to write a stored procedure in SQL which has multiple select statements in it and pass each of those select statements to SSRS and create different reports. When i write the select statements SSRS only picks up on the columns from the first select (Here is an extract of my select statemnets in my stored procselect 'Summary of Total Tax/Total Sales for Date : ' + convert(varchar,getdate()-14,106 ) as Title, sum(est_tax_price)/sum(est_item_price) as Estimated_Tax_Sales, sum(act_tax_price)/sum(act_item_price) as Actual_Tax_Sales,(sum(act_tax_price)/sum(act_item_price))-( sum(est_tax_price)/sum(est_item_price) ) as Difference, cast((sum(act_tax_price)/sum(act_item_price))-( sum(est_tax_price)/sum(est_item_price) ) /sum(act_tax_price)/sum(act_item_price) *100 as decimal(8,2)) as Pct_tax_differenceFROM amazon_orders_difference_reportwhere cast("create_date" as datetime ) between getdate()-14 and getdate()SELECT order_id, supplier_order_id, category, create_date, est_ship_price, act_ship_total, diff_ship_price, Pct_ship_difference as Pct_ship_differenceFROM amazon_orders_difference_reportwhere cast("create_date" as datetime ) between getdate()-14 and getdate()and Pct_ship_difference != 0unionSELECT null,'SHIP_TOTALS'as Total,null,null, sum(est_ship_price) as est_ship_price, sum(act_ship_total) as act_ship_total, sum(diff_ship_price) as diff_ship_price, cast(sum(diff_ship_price)/sum(act_ship_total) *100 as decimal(8,2)) as Pct_ship_differenceFROM amazon_orders_difference_reportwhere cast("create_date" as datetime ) between getdate()-14 and getdate()and Pct_ship_difference != 0order by 2 desc |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-04-12 : 14:04:30
|
ssrs can only take metadata info from single resultset. so either you've to use two datasets one with each query or link both selects using union operator after making number of columns and column types same. |
|
|
|
|
|
|
|