Sören Schönfeld Posted September 25, 2019 Share Posted September 25, 2019 Hi all, what is the most efficient way to create a view that dynamically UNIONs new (CSV) tables Background: Let us assume that there is a folder containing an unknown number of CSV files (of the same structure). For example, one CSV per day or so. How do I set up the TDV data source, TDV Views etc. to create such a dynamic UNION of these files On a side note: When I have an unknown number of SQL Tables I could use SQL Cursor statmenents (explained here https://dba.stackexchange.com/questions/149335/create-a-view-that-dynami... ) to create such dynamich UNIONs. Is there a related TDV example available Thank you!!! Link to comment Share on other sites More sharing options...
Motsu Aboshi Posted September 25, 2019 Share Posted September 25, 2019 Easiest way to do this, is probably to use Dynamic SQL with an SQL script: - take parameters to the SQL script that allow you to determine which CSVs you need (or just pull all of the ones for that data source) - iterate the CSV filenames to build SQL with a union - return a cursor for the dynamic sql - wrap in a view if needed - publish This requires the CSVs to have the same number of columns, or be padded to that requirement. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now