Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

SP to iterate over multiple tables, writing piped results to temp table

$
0
0

Requirement - I have to extract a lot of data out of our ERP database for prospective customer SARs under GDPR.

Assume the Temporary Table is something like the following:

SQL
createtable#GDPR_Temp(Customervarchar(12),Origin_TableVarchar(15),Datatext,Date_Readdatetime)

The Origin_Table field will be the table name queried.

The Data field will be the flat pipe-delimited text export of the data.

Example Origin Table:

SQL
selectrtrim(isnull(customer,'')),rtrim(isnull(address_ref,'')),rtrim(isnull(addr_desc,'')),rtrim(isnull(contact,'')),rtrim(isnull(title,'')),rtrim(isnull(initials,'')),rtrim(isnull(full_name,'')),rtrim(isnull(organisation,'')),rtrim(isnull(pobox,'')),rtrim(isnull(address,'')),rtrim(isnull(city,'')),rtrim(isnull(county,'')),rtrim(isnull(country,'')),rtrim(isnull(postcode,'')),rtrim(isnull(...

Viewing all articles
Browse latest Browse all 4871

Trending Articles



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