I'm a novice in writing SQL-code. Last time I did it was about 10 years ago, but now I've run into a situation where I need to get a quick refresh. What I basically want to do is an automated export from each table that contains data in each database to
CSV-files, except the system databases, and store it in a directory structure.
We have started version handling some of the data in our databases, and to make it easier for the developers to know which data is versioned we've decided to setup a database with only that data, and then export it after every change to files.
So far, this is what I have:
select 'exec master..xp_cmdshell'
+ ' ''
+ ' ' + TABLE_CATALOG + '.' + TABLE_SCHEMA + '.' + TABLE_NAME
+ ' out'
+ ' c:\Temp\'
+ TABLE_CATALOG + '.' + TABLE_SCHEMA + '.' + TABLE_NAME + '.csv'
+ ' -c -t; -T -S' + @@servername
where TABLE_TYPE = 'BASE TABLE'
This gives me a list of exec-commands for each table in a database. What I need to add, that I don't kno
View Complete Post