Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin.
Search for scripts directly from SSMS, and instantly access any saved scripts in your
SSC briefcase from the favorites tab.
Download now (direct download link)
Thank this author by sharing:
By Samardeep Khera,
Be careful for following lines
replace <element> with your local environment elements
remove "<" ," >" signs
e.g. use master
1 use <database>
8 @dbName varchar(100) = '<database name>',
9 @sql varchar(8000) = 'select <col1,col2,col3....col4> from <table>',
10 @fullFileName varchar(100) = '<output file path>'
57 SET @bcpCommand = @bcpCommand + ' C:\Temp\test.csv -c -w -T -U sa -P sa","-CRAW' 58 EXEC <database>..xp_cmdshell @bcpCommand
Difference between varchar(max) and varchar(8000)
any downside to VARCHAR(MAX)?
Usage of VARCHAR(MAX)