tsql - How to create a 'sanitized' copy of our SQL Server database? -
we're manufacturing company, , we've hired couple of data scientists patterns , correlation in our manufacturing data. want give them copy of our reporting database (sql 2014), must in 'sanitized' form. means table names converted 'table1', 'table2' etc., , column names in each table become 'column1', 'column2' etc. there 100 tables, having 30+ columns, , tables have 2b+ rows.
i know there hard way this. manually create each table, sanitized table name , column names, , use ssis bulk insert rows 1 table another. rather time consuming , tedious because of manual ssis column mapping required, , manual setup of each table.
i'm hoping has done before , has faster, more efficienct, way.
by way, 'sanitized' database have no indexes or foreign keys. also, may seem make sense why want this, agreed our director of manufacturing , data scientists, first round of analysis involve many rounds.
you want scrub data , objects, correct? here do.
- restore backup of db.
- drop objects not needed (indexes, constraints, stored procedures, views, functions, triggers, etc.)
- create table 2 columns, populate table, each row has orig table name , new table name
- write script iterates through table, roe row, , renames tables. better yet, put data excel, , create third column builds tsql want build, cut/paste , execute in ssms.
- repeat step 4, columns. best query sys.columns objects need, put excel, , build tsql
- repeat again other objects needed.
backip/restore quicker dabbling in ssis , data transfer.
Comments
Post a Comment