Inserting Greek characters

  • Hi

    I am inserting "Greek" characters from insert statement calling from a coldfusion page into Sqlserver table. The filed type is "NVarchar".

    If i use Insert into tab1 values(N'#val1#',N'#val2#') and i could insert greek in database. Is there any way that i can convert this code into a storedprocedure that will take 2 parameters (Greek or chinese characters) and insert into the table.

    Thanks

    Sridhar

  • Sure, something like this:

    create proc usp_Dosomething @val1 nvarchar(10), @val2 nvarchar(10)

    as

    insert into.....

  • Thanks for reply.

    i pasted the actual stored procedure i created and when i send data to this stored procedured it is converting data to "?????".

    Thanks

    Sridhar

    CREATE PROCEDURE [dbo].[InsRelease]

    @userid int,

    @Organisationid int,

    @Title nvarchar(500),

    @Summary ntext,

    @Maintext ntext,

    @NotesForEditors ntext,

    @PubDetails ntext,

    @PosterIsContact int,

    @ContactName nvarchar(500),

    @ContactOrganisation nvarchar(500),

    @ContactEmail nvarchar(500),

    @ContactPhone nvarchar(500),

    @IsEmbargoed int,

    @EmbargoDate datetime,

    @PostingDate datetime,

    @PostingLanguage int,

    @preEmbargo ntext,

    @postEmbargo ntext,

    @ReleaseURL nvarchar(500),

    @Keywords nvarchar(500),

    @status nvarchar(50),

    @sendemails int,

    @NotesTOAlphagalileo nvarchar(500),

    @sitesection int

    AS

    BEGIN

     Insert into notices

      (UserId, Organisationid, Title, Summary, Maintext,

      NotesForEditors, PubDetails, PosterIsContact, ContactName,

      ContactOrganisation, ContactEmail, ContactPhone, IsEmbargoed,

      EmbargoDate, PostingDate, PostingLanguage, preEmbargo,

      postEmbargo, ReleaseURL, Keywords,Status,sendemails,

      NotesTOAlphagalileo,sitesection)

     Values

      (@UserId, @Organisationid, @Title, @Summary, @Maintext,

      @NotesForEditors, @PubDetails, @PosterIsContact, @ContactName,

      @ContactOrganisation, @ContactEmail, @ContactPhone, @IsEmbargoed,

      @EmbargoDate, @PostingDate, @PostingLanguage, @preEmbargo,

      @postEmbargo, @ReleaseURL, @Keywords,@Status,@sendemails,

      @NotesTOAlphagalileo, @sitesection)

    END

    GO

  • If you run this SP in QA do you get the ???? in the data? If not I would start looking at what is happening when you call the SP from your app. My guess is that the data is getting converted before it get's to SQL Server. To check this turn on profiler with the SQLProfilerTSQL_Replay template and capture what is being passed to the database. My guess is that you will find that the data has already been converted to the ???? rather than the unicode characters you are expecting.




    Gary Johnson
    Microsoft Natural Language Group
    DBA, Sr. DB Engineer

    This posting is provided "AS IS" with no warranties, and confers no rights. The opinions expressed in this post are my own and may not reflect that of my employer.

  • Thanks for reply.

    Yes i tried directly from QA. It inserted "???ß??? ?a? d????s? t?? ep?te??µ?t?? t?? e???pa???? ep?st?µ?????? ?a? te?????????? ??e??a?," in table instead of greek text.

    As i mentioned previously i was using

    insert into tbl values (N'val1').

    Is there any way that i can specify 'N' in front of field name in values in the above stored procedured.

    Thanks

    Sridhar

  • Something else to consider is the Collation of the database and/or the columns you are trying to insert into.  If the collation is not set to handle the characters the server may interpret the information to be ????

    SELECT *

    FROM ::fn_helpcollations()

    will give you all the different collations and then you can set up the collation you want for the Server, Database, Table, or Column level

     

    Good Luck



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • After running the select query i get the below data related to Greek. Could you please explain me what should i need to change to solve the problem.

    thanks

     

    namedescription
    Greek_BINGreek, binary sort
    Greek_CI_AIGreek, case-insensitive, accent-insensitive, kanatype-insensitive, width-insensitive
    Greek_CI_AI_WSGreek, case-insensitive, accent-insensitive, kanatype-insensitive, width-sensitive
    Greek_CI_AI_KSGreek, case-insensitive, accent-insensitive, kanatype-sensitive, width-insensitive
    Greek_CI_AI_KS_WSGreek, case-insensitive, accent-insensitive, kanatype-sensitive, width-sensitive
    Greek_CI_ASGreek, case-insensitive, accent-sensitive, kanatype-insensitive, width-insensitive
    Greek_CI_AS_WSGreek, case-insensitive, accent-sensitive, kanatype-insensitive, width-sensitive
    Greek_CI_AS_KSGreek, case-insensitive, accent-sensitive, kanatype-sensitive, width-insensitive
    Greek_CI_AS_KS_WSGreek, case-insensitive, accent-sensitive, kanatype-sensitive, width-sensitive
    Greek_CS_AIGreek, case-sensitive, accent-insensitive, kanatype-insensitive, width-insensitive
    Greek_CS_AI_WSGreek, case-sensitive, accent-insensitive, kanatype-insensitive, width-sensitive
    Greek_CS_AI_KSGreek, case-sensitive, accent-insensitive, kanatype-sensitive, width-insensitive
    Greek_CS_AI_KS_WSGreek, case-sensitive, accent-insensitive, kanatype-sensitive, width-sensitive
    Greek_CS_ASGreek, case-sensitive, accent-sensitive, kanatype-insensitive, width-insensitive
    Greek_CS_AS_WSGreek, case-sensitive, accent-sensitive, kanatype-insensitive, width-sensitive
    Greek_CS_AS_KSGreek, case-sensitive, accent-sensitive, kanatype-sensitive, width-insensitive
    Greek_CS_AS_KS_WSGreek, case-sensitive, accent-sensitive, kanatype-sensitive, width-sensitive
  • I think if you create the table like below it might help

     

    CREATE TABLE

    (

    [Field1] [VARCHAR] (255) NOT NULL COLLATE Greek_BIN

    ) ON [PRIMARY]

    as an example (I think I did the syntax correctly) and then try to insert the greek characters.  If the above code doesn't work you can create a table and then through EM modify the collation per column.

    The above collation is just an example I don't know if you need case sensitivity, accent etc..  If you do pick one of the other collations.

    Please let me know if this works

     

    Good Luck



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • I tried changing the COLLATE of one field but it didn't work.

    Any how I cannot create new tables because there is already more than 10,000 records in each table. And those fields needs to store English, French, Basque, German, Greek content. 

    will effect other languages if i change the collate to Greek BIN?

    I could use insert into... values(N'val1',N'val2) to insert Greek text.

    I am looking some thing equalent to the same syntax in stored procedures.

    Thanks

    Sridhar

  • Can you post the script you used to call the SP?

     

    It should be something like

    EXEC yoursp N'Greekcharfield1', N'...etc...

    OR

    DECLARE @GreekField1 nvarchar(500)

    SET @GreekField1 = N'Greekdata'

    EXEC yoursp @GreekField1

     

    BTW: Rather than using the Greek_BIN collation I would use Latin1_GENERAL_Bin. This will support all languages. I currently have my default collation to this and we have German, Chinese, Japanese, Spanish, French, and English all in the same database. We've never had a problem unless we forget to use the N to indicate unicode data.

    Again I would like to make sure that you have actually run profiler to see what is actually being passed to the database from your app. My guess is that it is not treating your data as unicode when it is calling the SP.




    Gary Johnson
    Microsoft Natural Language Group
    DBA, Sr. DB Engineer

    This posting is provided "AS IS" with no warranties, and confers no rights. The opinions expressed in this post are my own and may not reflect that of my employer.

Viewing 10 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply