DECLARE @FileName varchar(50), @bcpCommand varchar(2000) SET @FileName = 'C:\result.txt' SET @bcpCommand = 'bcp "SELECT * FROM payroll..employee_v ORDER BY emp_no" queryout "' SET @bcpCommand = @bcpCommand + @FileName + '" -U sa -P 123 -c' EXEC master..xp_cmdshell @bcpCommand
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)