July 28, 2015 at 10:53 am
Hi all,
I'm new to powershell and found 2 powershell comands to open a file encoded in UTF-8 and transforms it to unicode encoding... Which is exactly what I was looking for.
I tried it directly in a powershell window and it works perfectly.
$Content = get-content d:\VisualCronTemp\testExport.csv
$Content | out-file -filepath d:\VisualCronTemp\Output.csv -encoding Unicode
Now, I'm trying to automate this using a stored procedure that would do these 2 commands
Is it even possible? Does anyone know how?
thanks in advance
JG
July 28, 2015 at 11:12 am
figured it out...
To convert a UTF8 file to unicode (this helps when you want to Bulk insert a UTF8 file which is no longer supported by MS SQL server since SQL 2005)
Declare @SQLStr varchar(8000), @SourcePathFile varchar(300), @DestinationPathFile varchar(300)
set @SourcePathFile = 'd:\VisualCronTemp\testExport.csv'
set @DestinationPathFile = 'd:\VisualCronTemp\Output.csv'
Set @SQLStr = 'xp_cmdshell ''powershell.exe -command "get-content ' + @SourcePathFile + ' | out-file -filepath ' + @DestinationPathFile + ' -encoding Unicode"'''
Exec (@SQLSTr)
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy