Last active
October 24, 2015 13:14
-
-
Save ScottGuymer/b16319b00f9650f822c5 to your computer and use it in GitHub Desktop.
Create a list of commands to dump all tables to csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select 'exec master..xp_cmdshell' | |
+ ' ''' | |
+ 'bcp' | |
+ ' "' + TABLE_CATALOG + '.' + TABLE_SCHEMA + '.[' + TABLE_NAME + ']"' | |
+ ' out' | |
+ ' "C:\temp\' | |
+ TABLE_CATALOG + '.' + TABLE_SCHEMA + '.' + TABLE_NAME + '.csv"' | |
+ ' -c -t,' | |
+ ' -T' | |
+ ' -S' + @@servername | |
+ '''' | |
from INFORMATION_SCHEMA.TABLES | |
where TABLE_TYPE = 'BASE TABLE' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment