Skip to main content
Participant
June 17, 2010
Answered

does CFstoredProc support unicode?

  • June 17, 2010
  • 2 replies
  • 1099 views

I need to pass mandarin chinese characters into a sql server stored procedure. Usually I would do this using the following code:

            <cfprocparam
                type="in"
                dbvarname="@newText"
                value="百科全书"   <!--- want to pass in mandarin characters --->
                cfsqltype="CF_SQL_NVARCHAR"
                maxlength="50">
            <cfprocparam
                type="out"
                dbvarname="@returnCode"
                variable="idNumber"
                cfsqltype="CF_SQL_INTEGER">
        </cfstoredProc>

my stored procedure looks like this:

CREATE PROCEDURE [dbo].[testTextInput]
    @newText nvarchar(50),
AS

            INSERT INTO testTextTable (someText)
            VALUES (@newText)

RETURN

my sql table has the field "someText" declared as nvarchar(50)

when i run this the text input into my sqlServer table is not in mandarin. Wondering if cfstoredProc supports unicode, or if I am doing something wrong. If it doesn't support unicode, then how do i do this, will it work if i use <cfquery - instead?

thank you in advance,

Deb

    This topic has been closed for replies.
    Correct answer tooMuchTrouble

    if you're sure your column is actually Nvarchar, have you turned on "Enable High

    ASCII characters and Unicode for data sources configured for non-Latin

    characters" for that datasource? its under the advanced menu.

    and come to think of it, you're using the JDBC driver not ODBC, right?

    2 replies

    tooMuchTroubleCorrect answer
    Inspiring
    June 18, 2010

    if you're sure your column is actually Nvarchar, have you turned on "Enable High

    ASCII characters and Unicode for data sources configured for non-Latin

    characters" for that datasource? its under the advanced menu.

    and come to think of it, you're using the JDBC driver not ODBC, right?

    dh_bldrAuthor
    Participant
    June 21, 2010

    Thanks!

    this works i needed the jdbc driver, and newer version of ColdFusion

    Inspiring
    June 17, 2010

    My facsimile of your code works fine for me (running CF9, SQL Server 2k8).

    CF:

    <cfprocessingdirective pageencoding="utf-8">
    <cfstoredproc procedure="usp_testTextInput" datasource="scratch">
        <cfprocparam
            type="in"
            value="百科全书"   <!--- want to pass in mandarin characters --->
            cfsqltype="CF_SQL_NVARCHAR"
            maxlength="50"
        >
    </cfstoredProc>


    Proc:

    CREATE PROCEDURE [dbo].[usp_testTextInput]
        @newText nvarchar(50)
    AS
                INSERT INTO testTextTable (someText)
                VALUES (@newText)

    RETURN

    Table spec:

    CREATE TABLE [dbo].[testTextTable](

        [id] [int] IDENTITY(1,1) NOT NULL,
        [someText] [nvarchar](50) NULL,
    CONSTRAINT [PK_testTextTable] PRIMARY KEY CLUSTERED
    (
        [id] ASC
    )

    I've also set the DSN to handle unicode.

    --

    Adam