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.

 All Forums
 SQL Server 2008 Forums
 Analysis Server and Reporting Services (2008)
 SSRS Query

Author  Topic 

Villanuev
Constraint Violating Yak Guru

478 Posts

Posted - 2012-02-27 : 22:21:45
Guys,

I have to develop report through SSRS.
Its advisable to create temp table inside the dataset query?
do i need to drop this temp table?
what can you say with this approach.

any suggestion to facilitate my query.

Here is my query.


--Create temporary table
Create table #PurchReceive
(
Packingslipid nvarchar(30), deliverydate datetime, itemid nvarchar(35),
name nvarchar(1000), ordered numeric(28,12), Qty numeric(28,12), remain numeric(28,12),
dimension nvarchar(10), purchid nvarchar(30), internalpackingslipid nvarchar(30),
inventdimid nvarchar(30), dataareaid nvarchar(4)
)

--pull out all records satisfied by issued critera and append to temporary table
Insert into #PurchReceive(Packingslipid,deliverydate,itemid,name,ordered,Qty,remain,
dimension,purchid,internalpackingslipid,inventdimid,dataareaid)
Select
v.PACKINGSLIPID
,v.DELIVERYDATE
,v.ITEMID
,v.NAME
,v.ORDERED
,v.QTY
,v.REMAIN
,v.DIMENSION
,v.PURCHID
,v.INTERNALPACKINGSLIPID
,v.INVENTDIMID
,v.DATAAREAID
From VENDPACKINGSLIPTRANS v
Where v.DATAAREAID =(@Dataareaid)
and v.DELIVERYDATE >=(@Startdate) and v.DELIVERYDATE <(@Enddate)


--Join from other table for data manipulation and relatte other fields.
Select p.PACKINGSLIPID
,p.DELIVERYDATE
,p.ITEMID
,p.NAME
,p.ORDERED
,p.QTY
,p.REMAIN
,p.DIMENSION
,p.PURCHID
,p.INTERNALPACKINGSLIPID
,p.INVENTDIMID
,p.DATAAREAID
From #PurchReceive p
Inner Join PURCHLINE l
On l.ITEMID = p.itemid COLLATE Chinese_Taiwan_Stroke_CI_AS
and l.PURCHID = p.purchid COLLATE Chinese_Taiwan_Stroke_CI_AS
Left Outer Join PURCHTABLE u
On p.PURCHID = u.PURCHID COLLATE Chinese_Taiwan_Stroke_CI_AS
Left Outer Join INVENTDIM i
On p.INVENTDIMID = i.INVENTDIMID COLLATE Chinese_Taiwan_Stroke_CI_AS
and i.DATAAREAID = (@Dataareaid)
Left Outer Join INVENTTABLE t
On t.ITEMID = p.ITEMID COLLATE nese_Taiwan_Stroke_CI_AS
order by p.purchid


Drop table #PurchReceive




Thank you in advance.
JOV

Jayam.cnu
Starting Member

45 Posts

Posted - 2012-02-27 : 23:54:46
YES its better to drop table... .. but it it will not give any problem with out dropping table also. but to maintain temp db accuracy we need to do ..
Go to Top of Page

Villanuev
Constraint Violating Yak Guru

478 Posts

Posted - 2012-02-28 : 00:49:55
Thanks for your reply.
Btw, how to do it in scripts if my table will start @ or declare table.
Go to Top of Page

Villanuev
Constraint Violating Yak Guru

478 Posts

Posted - 2012-03-05 : 02:49:48
Guys,

How would i place an error message indicate no records found based on the criteria in SSRS report. thanks.

Go to Top of Page

sandesh.ravi
Posting Yak Master

110 Posts

Posted - 2012-03-09 : 12:30:03
Table variables are automatically cleared when the procedure or function goes out of scope, so you don't have to remember to drop or clear the data (which can be a good thing or a bad thing remember "release early"?).Table variable log activity is truncated immediately

Thanks,
Sandesh
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-09 : 12:34:54
quote:
Originally posted by Villanuev

Guys,

How would i place an error message indicate no records found based on the criteria in SSRS report. thanks.




there's a norows property for table. you can set message inside that which will get displayed when table returns no rows in report

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -