I have a requirement to move SSRS Snapshot data from one report server to another. I found a way to export the snapshots using PowerShell, but I do not see a way to import the data from there.
Thanks for the help in advance!
This SQL statement shows the snapshot data, but it appears that the data is being streamed into a BLOB in the Segment table.
select * from [dbo].[SnapshotData] SD
join dbo.History H
on h.SnapshotDataID = sd.SnapshotDataID
join dbo.Catalog C
on c.ItemID = h.ReportID
join dbo.SegmentedChunk SC
on SC.SnapshotDataId = SD.SnapshotDataID
join dbo.ChunkSegmentMapping CSM
on csm.ChunkId = sc.ChunkId
join dbo.Segment S
on s.SegmentId = csm.SegmentId
where 1=1
order by
c.Path
, sd.CreatedDate DESC
I'm trying to execute the below query to export the results to CSV. I'm able to export the data to CSV but the headers were missing in the file. Is there anyway that we can achieve this? Im executing the file in the form "db2 -tvmf D:\Db.sql"
connect to ****** user ***** using ******
export to "D:\Vikas.csv" OF DEL MESSAGES
select
'ROW_NUM',
'DETAIL_TYPE_CD',
'ADMIN_FEES_TICKET',
'ADMINISTRATIVE_FEES',
'BASE_RENT',
'CITATIONS',
'COLLECTION_REPO_FEES',
'DESC',
'EFFECTIVE_DATE',
'LATE_CHARGE',
'MISC_FEE',
'STATUS_CD',
'ROW_ID',
'ROW_ID',
'BUILD',
'REVERSE_FLG',
'NSF_FLG',
'PR_CON_ID',
'PROC_DATE',
'PROPERTY_TAX',
'REGISTRATION_FEES',
'REPAIR_FEES',
'SALES_TAX',
'TERMINATION_FEES',
'TOTAL_TRANS',
'TRANSACTION_TYPE'
from sysibm.sysdummy1
UNION ALL (select
T1.ROW_NUM,
T5.DETAIL_TYPE_CD,
T1.ADMIN_FEES_TICKET,
T1.ADMINISTRATIVE_FEES,
T1.BASE_RENT,
T1.CITATIONS,
T1.COLLECTION_REPO_FEES,
T1.DESC,
T1.EFFECTIVE_DATE,
T1.LATE_CHARGE,
T1.MISC_FEE,
T2.STATUS_CD,
T4.ROW_ID,
T3.ROW_ID,
T2.BUILD,
T1.REVERSE_FLG,
T1.NSF_FLG,
T2.PR_CON_ID,
T1.PROC_DATE,
T1.PROPERTY_TAX,
T1.REGISTRATION_FEES,
T1.REPAIR_FEES,
T1.SALES_TAX,
T1.TERMINATION_FEES,
T1.TOTAL_TRANS,
T1.TRANSACTION_TYPE
FROM
SIEBEL.LSE_INPHIST_VIEW T1
LEFT OUTER JOIN SIEBEL.S_ASSET T2 ON T1.ACCOUNT_NUM = T2.ASSET_NUM
LEFT OUTER JOIN SIEBEL.S_ASSET_CON T3 ON T2.ROW_ID = T3.ASSET_ID AND
T3.RELATION_TYPE_CD = 'Obligor'
LEFT OUTER JOIN SIEBEL.S_ASSETCON_ADDR T4 ON T3.ROW_ID =
T4.ASSET_CON_ID AND T4.USE_TYPE_CD = 'Bill To'
LEFT OUTER JOIN SIEBEL.S_PROD_INT T5 ON T2.PROD_ID = T5.ROW_ID
WHERE
(T1.ACNT_ID = '01003501435'))
ORDER BY
T1.ACNT_ID DESC,T1.PROC_DATE DESC WITH UR
I have included the updated query now in the post.
The Db2-LUW export command lacks the ability to add columns headers to the output file. It only exports whatever is in the SELECT statement.
So when you want to have column-headers in the CSV file you have different options.
One way to do it (when there is no order by) is to make the SELECT statement into a UNION of two queries, the first query returns one row which is the list of column names, then union this with your real query. It means you must hand-craft the column-names of the first query to match the real second query. In your case for example it might look like:
SELECT 'row_num', 'detail_type_cd', ....
from sysibm.sysdummy1
UNION
SELECT t1.ROW_NUM, T5.DETAIL_TYPE_CD, ...
(you have to manually make the column-names , put them in single-quotes etc. But if you want Db2 to work out the column names you can use a technique like here ).
If you have an order by you can run two separate export commands (i.e. no union) outputting to two separate output files, and then use operating system functions to concatenate the output files like this:
export to headers.csv select 'colname1','colname2'...from sysibm.sysdummy1;
export to data.csv select ...
-- for MS-windows
!copy /a headers.csv + data.csv data_with_headers.csv ;
Another (possibly simpler) way to do it , with v11.5 (and higher) versions of Db2-LUW , is to not use the export command, but instead to create an external table, which lets you specify an option includeheader on among many other options for CSV files. You can search this site for examples, and reference the documentation.
Anyone know what is the ORM function for joining multiple db tables in ERPNext?
I need query result from 2 DB tables join using script report
*I don't need query report answer since i already have it. I only looking for an example do it using script report
Frappe currently doesn't have ORM support for joining tables. You might have to use frappe.db.sql for the time being.
data = frappe.db.sql(
"""
select tb1.name from tabTable1 as tb1
left join tabTable2 as tb2 on tb1.name = tb2.employee_name;
"""
);
return data
I have a table with a column (value) that holds different types of information that I need to parse into separate columns. In postgresql, I can easily do this:
SELECT m1.value shipname
, m2.value agent
FROM maritimeDB m1
JOIN maritimeDB m2
ON m1.rowID = m2.rowID
AND m2.itemname = 'Agent'
WHERE m1.rowID
IN (SELECT DISTINCT rowID FROM maritimeDB WHERE entity='9999')
AND m1.itemname='shipname'
I want to do this same sort of query in BigQuery (with JOIN becoming LEFT JOIN), but I get this error:
Error: ON clause must be AND of = comparisons of one field name from each table, with all field names prefixed with table name.
Any suggestions?
This error is coming from Legacy SQL dialect (which is default). This query should work with Standard SQL dialect which supports arbitrary JOIN predicates.
I am trying to create a tde file from a live data source. I am connecting to multiple materialized views in postgres so the data source is a custom sql query. Everything in the workbook runs fine while live but when I try to extract the data, I receive the error:
ERROR: column reference "datasource" is ambiguous; Error while executing the query
Unable to create extract
I do have multiple tables with the same field name so I aliased each of the fields accordingly in my custom query. It seems that when Tableau creates their query for extract, the aliasing isn't recognized. Any help is very appreciated.
SELECT
i.trx_line_id
,i.datasource
,ie.category_type
,ss.trx_line_id
,ss.datasource
,pl.pl_cd
FROM invoice i
LEFT JOIN sales_structure ss ON i.trx_line_id = ss.trx_line_id
LEFT JOIN invoice_ext ie ON i.trx_line_id = ie.trx_line_id
LEFT JOIN product_level pl ON i.pl_cd = pl.pl_cd
WHERE ss.sales_team_rpt IN ('a','b')
You are returning to Tableau a set of data where fields (datasource and trx_line_id) have the same name. A simple fix would be to alias those fields:
SELECT
i.trx_line_id AS invoice_line_id, -- Aliased
i.datasource AS invoice_datasource, -- Aliased
ie.category_type,
ss.trx_line_id AS sales_structure_line_id, -- Aliased
ss.datasource AS sales_structure_datasource, -- Aliased
pl.pl_cd
FROM
invoice i
LEFT JOIN
sales_structure ss ON i.trx_line_id = ss.trx_line_id
LEFT JOIN
invoice_ext ie ON i.trx_line_id = ie.trx_line_id
LEFT JOIN
product_level pl ON i.pl_cd = pl.pl_cd
WHERE
ss.sales_team_rpt IN ('a','b');