0

I am using sql server database drivers in codeigniter and I am executing the following query:

 select A.inst_name,Substring((Select ',' + cast(B.program_id as varchar(15))   
                               From    k12_dms_inst_programs B
                               Where B.inst_id=A.id For XML Path('')),2,8000) As EmployeeList
 From k12_dms_institution_master A
 Group by A.inst_name,A.id

which is working absolutely fine in SSMS.

But when I am trying to execute the same query using Codeigniter I am getting the following error:--

Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier.

1 Answer 1

1

Found some solutions on php.net

  1. MSSQLNewbie 19-Sep-2011 06:34

    In /etc/freetds/freetds.conf add these two lines (last two):
    [global]
    ;tds version = 4.2
    tds version = 8.0  
    client charset = UTF-8
    
    You can edit "charset" in php.ini too (but you don't need if you did it previously in freetds.conf):  
    ; Specify client character set.. 
    ; If empty or not set the client charset from freetds.comf is used 
    ; This is only used when compiled with FreeTDS mssql.charset = "UTF-8"
    
    Use nchar/nvarchar/ntext column types if you need unicode support.
    
  2. dann dot farquhar at iteams dot org 24-Sep-2009 11:45

    I found that changing the version in /etc/freetds.conf from 4.2 to 8.0
    fixes this problem without having to make any changes to the SELECT
    statement
    
  3. huberkev11 at hotmail dot com 12-May-2006 01:47

    This is because you are using column types of like ntext instead of
    text.  There are 2 solutions.
    
    1  Change all ntext column types to text or
    2  Your query must look like: SELECT CAST(field1 AS TEXT) AS field1 FROM table
    

Hope they will help.

Sign up to request clarification or add additional context in comments.

1 Comment

@user1163513 tell us which of them did help you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.