Text field on SQL Server is not good to store binary data because it is not reliable and often SQL Server corrupts binary data in text fieldAnd
When binary data passed to SQL Server, they're encoded to match the format required for SELECT statement in T-SQL.In my test I'm doing this:
* To Store a Word Doc in SQL Server *********************************** CLEAR =SQLDISCONNECT(0) x = GETFILE("Doc","Word File") Y = FILETOSTR(x) cStringConnect =("DRIVER={SQL Server};SERVER=BOSS700;UID=xxx;PWD=xxx;DATABASE=Atuante2") nID = SQLSTRINGCONNECT(cStringConnect) csql = "INSERT INTO teste1(texto) Values(?Y)" a = SQLEXEC(nID,csql) IF a < 1 =AERROR(my_erro) DISPLAY MEMORY LIKE my_erro ELSE WAIT WINDOW "OK" TIMEOUT 1 ENDIF * To Get the Data of a Word Doc from SQL Server *********************************************** cStringConnect =("DRIVER={SQL Server};SERVER=BOSS700;UID=xxx;PWD=xxx;DATABASE=Atuante2") nID = SQLSTRINGCONNECT(cStringConnect) csql = "SELECT * FROM teste1 Where codigo > 2" a = SQLEXEC(nID,csql,"Cur_test") IF a < 1 =AERROR(my_erro) DISPLAY MEMORY LIKE my_erro ELSE WAIT WINDOW "OK" TIMEOUT 1 SELECT("Cur_test") =STRTOFILE(Cur_test.texto,"AMD2.DOC") ENDIFI made some test and the code works fine with SQL Server, and I'm able to get the value from a Text field in a SQL Table, and transform it into a Word document again without problems.