Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

The query not working in Report Builder 3.0 Dataset

$
0
0

Dear all,

 The following query is working fine in SQl but not in Query designer of Report Builder could you please help me rectify the same.

createtable#SampleTable
(
auto_id int
identity(1,1),
JobId int
,
[parameters] XML
)

INSERTINTO#SampleTable(JobId,[parameters])
select ROOTOBJID,[parameters]from
[HistorianStorage].[SIMATIC_BATCH_SBO_262-64-6740100_v8_00_00].[Event]
where ROOTOBJID =45and Name like'c%'and ObjectExstate =194

-- First create a temp table to hold all the values
createtable#TempTableToHoldRecords
(
job_id int
,
actmatname varchar
(100),
actvalue int
)

-- Loop through all the records and insert into above temp table.
DECLARE@AutoId int
DECLARE@Data XML
DECLARE@job_id int

select@AutoId = min(auto_id)from#SampleTable
while(@AutoId ISNOTNULL)
BEGIN

set@Data ='';

select@job_id = JobId,@Data =[parameters]from#SampleTable where auto_id=@AutoId

INSERTINTO#TempTableToHoldRecords
SELECT@job_id,
Parameter
.value('@actmatname','NVARCHAR(255)')AS actmatname,
Parameter
.value('@actvalue','NVARCHAR(255)')AS actvalue
FROM    @Data.nodes('/Parameters/Parameter') DataPage( Parameter );


deletefrom#SampleTablewhere auto_id =@AutoId
select@AutoId = min(auto_id)from#SampleTable
END

select job_id,actmatname,SUM(actvalue)from#TempTableToHoldRecords
GROUPBY actmatname, job_id

dropTABLE#TempTableToHoldRecords
dropTABLE#SampleTable


Thanks and Regards Shailendra Keep Smiling


Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>