sql >> Base de Datos >  >> RDS >> Sqlserver

Escribir en un archivo con xp_cmdshell en UTF-8

Finalmente lo logré escribiendo el resultado en un archivo temp.txt y agregando el siguiente comando de PowerShell para convertirlo a UTF-8:

-- Change encoding to UTF-8 with PowerShell 
SET @command = 'powershell -Command "Get-Content '[email protected]+'\temp.txt -Encoding Unicode | Set-Content -Encoding UTF8 '[email protected]+'\'[email protected]+'"';
EXEC xp_cmdshell @command;