2

I am trying to develop a script in SQL server or SSIS that it can detect a file with distinct encoding like UTF-8,ANSI,UCS-2,UTF-32 and so on.

I have searched for a lot of tools but I haven't found anything yet. Can anyone help me, please?

Thanks. I appreciate your help.

Francis
  • 1,798
  • 1
  • 26
  • 32
aospinab
  • 33
  • 3
  • Hi@aospinab, if you could also mark the below as an answer, it would be much appreciated. Thanks! – Francis Aug 31 '18 at 22:21

1 Answers1

2

I don't know if there is a specific tool that does exactly what you need (file encoding detection inside SQL Server).

However, you can write one that does the job inside SQL Server as per your requirements. The file encoding detection can easily be done in C# and IMHO a more elegant solution than trying to write one in SQL, if possible at all.

So you should write a C# function that does that and then host it inside SQL Server for execution.

Here is a post that explains how to detect any encoding in a file

Effective way to find any file's Encoding

And here is a blog post that explains how to register a C# method and execute it from SQL Server

http://www.codemahek.com/blog/execute-c-methods-from-sql-server

There should be enough information here for you to do what you want.

Welcome to Stackoverflow!

Francis
  • 1,798
  • 1
  • 26
  • 32