Skip to content

Instantly share code, notes, and snippets.

@vladaman
Created August 29, 2013 11:32
Show Gist options
  • Save vladaman/6376946 to your computer and use it in GitHub Desktop.
Save vladaman/6376946 to your computer and use it in GitHub Desktop.
Export all tables into individual files
/* MS SQL Commands */
exec sp_configure 'show advanced options', 1
RECONFIGURE
exec sp_configure 'xp_cmdshell', 1
RECONFIGURE
exec sp_MSforeachtable 'master..xp_cmdshell ''bcp "SELECT * FROM DBName.?" queryout "Z:\?.txt" -S localhost -T -c -q'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment