-
Notifications
You must be signed in to change notification settings - Fork 75
/
Report_Subreports.sql
58 lines (57 loc) · 1.2 KB
/
Report_Subreports.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
WITH
content_binaries
AS
(
SELECT
cat.[ItemID]
, cat.[Name]
, cat.[Path]
, cat.[Type]
, [TypeDescription] =
CASE cat.[Type]
WHEN 2 THEN 'Report'
WHEN 5 THEN 'Data Source'
WHEN 7 THEN 'Report Part'
WHEN 8 THEN 'Shared Dataset'
ELSE 'Other'
END
, [Content] = CONVERT(VARBINARY(MAX), cat.[Content])
FROM
[dbo].[Catalog] AS cat
WHERE
1=1
AND cat.[Content] IS NOT NULL
AND cat.[Type] = 2
)
,
content_binaries_format
AS
(
SELECT
bin.[ItemID]
, bin.[Name]
, bin.[Path]
, bin.[Type]
, bin.[TypeDescription]
, [Content] = --strip off the BOM if it exist
CASE
WHEN LEFT(bin.[Content], 3) = 0xEFBBBF THEN CONVERT(VARBINARY(MAX), SUBSTRING(bin.[Content], 4, LEN(bin.[Content])))
ELSE bin.[Content]
END
FROM
content_binaries AS bin
)
SELECT
cbf.[ItemID]
, cbf.[Name]
, cbf.[Path]
, cbf.[Type]
, cbf.[TypeDescription]
, cbf.[Content]
, [ContentVarchar] = CONVERT(VARCHAR(MAX), cbf.[Content])
, [ContentXML] = CONVERT(XML, cbf.[Content])
FROM
content_binaries_format AS cbf
WHERE
1=1
AND CONVERT(VARCHAR(MAX), cbf.[Content]) LIKE '%<subreport%';