Created
July 30, 2013 01:11
-
-
Save martin0258/6109359 to your computer and use it in GitHub Desktop.
Get a CSV file from database query result.
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
:: -U, user name | |
:: -P, password | |
:: -h-1 [removes column name headers from the result] | |
:: -s"," [sets the column seperator to ,] | |
:: -w 1000 [sets the row width to 1000 chars (need to be as wide as the longest row or it will wrap to the next line)] | |
:: -W [remove trailing spaces from each individual field] | |
:: set nocount on; set ansi_warnings off; [in SQL file to remove additional messages] > | |
:: extract source file | |
sqlcmd -S %SERVER% -d %DB_NAME% -U %ARG1% -P %ARG2% -h-1 -s"," -W -w 1000 -i "%SQL_FILE%" -o "%RAW_FILE%" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment