Encoding character type in sql server column

Hello,
I am having troubles during REPLACE character in sql server column due to fact that, it seems to me, SQL Server does not recognize two "the same" characters i.e., some of them it translates into another encoding system correctly while, some of
them, keeps untouched, as entered. Obviously, according to my understanding, they "look the same shape" but, obviously, belong to different encoding systems. How to change encoding system for some of them?
Namely, this UPDATE statement:
UPDATE TOP (4000000) tblName
SET       FirstName = N'Đ' + SUBSTRING(FirstName, 2, 8000)
WHERE (FirstName LIKE N'Ð%')
works fine for my case but, as you see, it replaces just the first occurrence. Could it be possible to expand  this pattern to all occurrences?

I'm not sure that I have fully understood what you want to achieve, but it seems that you want to replace occurrances of Latin Captial Letter Edh with Latin Capital Letter D with Stroke, which looks virtually identical in uppercase (but are entirely different
in lowercase). Or vice versa.
Using the glyphs is certainly bound to cause confusion, and I think the best for clarity is to use the nchar function. Or possibly upper in combination with the lowercase glyphs. As for entering the characters, the Character Map utility, which you find in
the  folder Accessories/System Tools folder in the Start Menu is useful.
Below is a script that demonstrates the techniques above. You can also see that the characters are considered equal in a accent-insensitive collation. (Well, at least Latin1_General. They are of course unequal in Icelandic and Croatian AI collations.)
CREATE TABLE tblName(FirstName nvarchar(20) NOT NULL)
INSERT tblName(FirstName)
VALUES(upper('eðh'))
SELECT FirstName, lower(FirstName)
FROM tblName
UPDATE dbo.tblName
SET FirstName = REPLACE(FirstName, nchar(208), nchar(272))
WHERE FirstName LIKE N'%' + nchar(208) + '%';
SELECT FirstName, lower(FirstName)
FROM tblName
SELECT CASE WHEN nchar(208) = nchar(272) COLLATE Latin1_General_CI_AI THEN 1 ELSE 0 END AS Equal
go
DROP TABLE tblName
Erland Sommarskog, SQL Server MVP, [email protected]

Similar Messages

  • How to delete number (00) in a SQL Server column ?

    how to delete number (00) in a SQL Server column ?
    example :
    column :        Births       before                     Births 
        after                          
                       199900                            
            1999
                       198200                               
         1982
                       200400                               
        2004
    help query

    You use REPLACE function to selectively replace text inside a string in SQL Server. The REPLACE function is easy to use and very handy with an UPDATE statement.
    SELECT Replace(births, '00', '')
    or
    update .....
    Also you can use STUFF()
    This function can be used for delete a certain length of the string and insert a new string in the deleted place.
    Select STUFF ('199900', 5, 2, '')
    --result 1900,1982,....
    Ahsan Kabir Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread. http://www.aktechforum.blogspot.com/

  • Syntax error when creating a user-defined table type in SQL Server 2012

    Why am I getting a syntax error when creating a user-defined table type in SQL Server 2014?
    CREATE TYPE ReportsTableType AS TABLE 
    ( reportId INT
    , questionId INT
    , questionOrder INT );
    Results:
    Msg 156, Level 15, State 1, Line 1
    Incorrect syntax near the keyword 'AS'.

    Hope these posts could help, 
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/37a45a9a-ed8c-4655-be93-f6e6d5ef44be/getting-incorrect-syntax-while-creating-a-table-type-in-sql-server-2008-r2?forum=transactsql
    Regards, Dineshkumar,
    Please Mark as Answer if my post answers your question and
    Vote as Helpful if it helps you

  • [[DataDirect][ODBC SQL Server Wire Protocol driver][Microsoft SQL Server]Column name or number of supplied values does not match table definition.]

    Hii ..
    need help on this ..
    This what I am doing ..
    I am using a DATAEXPORT function to export level0 data from my essbase 11.1.2.2 to Microsoft SQL 2008 tables.
    So what I did first I exported the level0 data to a flat file using DATAEXPORT and the created the SQL columns by the same  in that order only in my SQL table.
    When I run it fails with this error:
    ODBC Layer Error: [21S01] ==> [[DataDirect][ODBC SQL Server Wire Protocol driver][Microsoft SQL Server]Column name or number of supplied values does not match table definition.]
    [Tue Jul 23 18:26:07 2013]Local/dataexp/dataexp/admin@Native Directory/1209813312/Info(1021014)
    ODBC Layer Error: Native Error code [213]
    [Tue Jul 23 18:26:07 2013]Local/dataexp/dataexp/admin@Native Directory/1209813312/Error(1012085)
    Unable to export data to SQL table [dataexp]. Check the Essbase server log and the system console to determine the cause of the problem.
    [Tue Jul 23 18:26:07 2013]Local/dataexp/dataexp/admin@Native Directory/1209813312/Info(1021002)
    SQL Connection is Freed
    [Tue Jul 23 18:26:07 2013]Local/dataexp/dataexp/admin@Native Directory/1209813312/Warning(1080014)
    Transaction [ 0x1c50001( 0x51ee7d66.0x80342 ) ] aborted due to status [1012085].
    [Tue Jul 23 18:26:07 2013]Local/dataexp/dataexp/admin@Native Directory/1209813312/Info(1012579)
    Total Calc Elapsed Time for [test.csc] : [1.44] seconds
    =============================================================
    I did a simple test on my Sample.basic application then ..
    loaded the calc data to it and then used the below script to export to a flat file
    //ESS_LOCALE English_UnitedStates.Latin1@Binary
    SET DATAEXPORTOPTIONS
                    DataExportLevel "Level0";
                    DataExportOverwriteFile ON;
                    DataExportColFormat OFF;
                    DataExportDimHeader OFF;
    FIX(
                "Jan",
                "Sales",
                "Actual"
    /*DATAEXPORT "File" "," "/home/hypadmin/samtest.txt";*/
    DATAEXPORT "DSN" "Abhitest" "sample" "sa" "welcome1";
    ENDFIX
    out put as below:
    "Sales"
    "100-30","California"
    "Jan","Actual",145
    Now In sql I created only 3 columns with name Jan/Sales/Actual and when I run this script again with comments removed .. I get the same error as what I have got in my first test case with other application ..
    but when I create the columns with same name as what its in export
    Sales/100-30/Califirnia/Jan/Actual
    It created the new rows successfully ..
    So with this I think the error which I am getting with my other application might be because of the same column issue  .. but then I have created all the columns by looking at the export file only as I did in sample ..
    Any idea would be helpful ..
    Thanks
    Abhishek
    I

    First make sure you add
    DataExportRelationalFile ON;
    to your set commands it is missing
    I alwats like to also add
    DataExportColHeader dimensionName;
    so I am sure what dimension is getting put into the columns.
    Then count the number of dimensions in your outline (exclude attribute dimensions). You need at least that many columns in your table  -1 + the number of  members you will be returning as columns in the export
    Taking your example Sample basic has 5 dimensions
    Measures
    Years
    Scenario
    Product
    Market
    Since you did not specify a dataexportcolheader it took the dense dimension Scenario as the columns. Your fix statement is limiting that to one member. Doing the math
    5 -1 + 1 = 5 columns in your table which is what you found works.  Suppose you fixed on bothe Actual and budget in scenario then you would need 6 columns 5 -1 +2

  • Storing 6 millions values in SQL server columns

    Hi,
    How many values (size) I can store in single SQL server column.
    My Scenario,
    Column1    Column2      Column3
         1      ABC     1,2,3,........(6 millions values)  
         2      CDE     1,2,3,.......(6 millions values)  
    and problem is that I can't store them in rows. I need to store them in single column with comma separated.
    What would be the best way to store them and retrieve them faster. I am thinking about converting it to byte[] or something but not sure how much time it will take to convert to byte and  then again to text.

    and problem is that I can't store them in rows. I need to store them in single column with comma separated.
    No you don't! Unless, that is, you really like to hurt yourself. It's a basic idea that in a relational database that each cell holds an atomic value, and this what relational datbases are optimised for.
    That said, if all you want to do is to store a bunch of values that you will never look at in the database, but the database will act as an unintelligent data store you will only look at the values outside the database, then it
    could make sense. However, a warning: just because you think that there is no requirement today, don't be surprised that you are sooner or later are asked questions like: "which the highest value for ABC?", "Which value is the most
    frequent across ABCs and CDEs?". Questions that are very simple to answer is you have data in a properly designed data model. But extremely to painful to answer if your all values in a single column.
    But if you take this, path, yes, storing values in a varbinary(MAX) with four bytes (or whatever that is needed) per value would be the best thing. It takes up less space than a string, and with fixed length it's easier to find value 198713 if this would
    be nedded. You seem to be worried about conversion from byte to text. Why is not clear to me, since number are usally born binary. But obviously, I have no idea where you get these values from or how you would use them.
    My initial recommendation still stands: store each value in a single row.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Import IMAGE type from SQL Server to BLOB in Oracle

    Hello,
    Is there a way to import a IMAGE type from SQL Server to BLOB type in Oracle from one table to another through a database link?
    I'm waiting for an answer as soon as possible.
    Best regards,
    Florin
    Edited by: Florin Manole on Sep 10, 2008 11:53 AM

    Have you already configured a Heterogeneous Services and Generic Connectivity to create a database link from Oracle to SQL Server? I haven't tried copying IMAGE data from SQL Server via Heterogeous Services myself, but from the [data type map|http://download.oracle.com/docs/cd/B19306_01/server.102/b14232/apb.htm#sthref509] in the documentation, I would expect that it would work so long as the SQL Server ODBC driver maps the IMAGE data type to SQL_LONGVARBINARY
    Justin

  • Dealing with the DATE data type in SQL Server

    As you know, a date is stored in SQL Server as "yyyy-mm-dd" when using the DATE data type.  This is also how it displays when I pull it into my Access front-end (even if I set the field's format to Short Date.)
    I'd like to be able to display it based on the user's regional settings.  I know I can use the FORMAT method in VBA to change it to mm/dd/yyyy, but I have users in other countries and I don't want to have to maintain a number of different versions.
    Any idea how I can automatically display the date in my MS Access form based on the user's regional settings?
    Thanks.

    Your solution, however, does not address the root of the problem. Access thinks it is a text field because there is no such thing as a 'Date' data type in Access. You will run into problems anywhere in Access, that you expect it to perform as
    a Date/Time field. E.G. sorting, filtering. 'Date' is one of the newer data types in SQL Server 2008+. You should be using SQL Server DateTime or SmallDateTime data type. Access will recognize those as a Date/Time data type and treat them accordingly.

  • How can this encoding be saved in SQL Server 2008

    hi all,
    We are using Sql Server 2008, it has this collation set "SQL_Latin1_General_CP1_CI_AS". Please have a look at this file:
    https://drive.google.com/file/d/0BxWAyvJA9ZjCdkFNN3BXZUw3dEE/view?pli=1
    its a text file in text format (ascii test data format aka ATDF). Its coming from French vendor and it contains some French words. We have to parse this and upload data to sql server. We do that all the time except this file is not working. It just disturbs
    the way sql server is saving data for us, and upon showing this saved data on application UI, the correct letters don't display. The upload happens via the Bulk Insert command. Please guide as to where to start. Also please let me know exactly what this format
    is called, do we call it just unicodes, or some utf formats. I'm really ignorant when it comes to unicode. Thanks a lot!
    ..ab
    Ab

    Hi
    Please use Unicode data types on the SQL Server side. Please see the following document:
    http://msdn.microsoft.com/en-us/library/ms187828(v=SQL.105).aspx 
    Thanks
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • Can't registerOutParameter of cursor type in SQL Server 2000

    Hi, there,
    I'm using SQL Server 2000 and a type 4 JDBC driver for it from JRun 3.1. I wrote a stored procedure which has a Cursor (ResultSet) as an output parameter. But I used callStmt.registerOutParameter(1, java.sql.Types.OTHER);
    I got an exception:
    callable stmt class: allaire.jrun.db.jdbc.base.BaseCallableStatement
    java.sql.SQLException: [JRun][SQLServer JDBC Driver]The specified SQL type is not supported by this driver.
    I definitely want the cursor to be an output parameter in my SQL 2000 store procedure, rather than defining a store procedure without an output Cursor parameter and then use callStmt.getResultSet();
    Does any one knows a way to register an output parameter of type CURSOR in SQL Server 2000 JDBC?
    I know that with in Oracle JDBC driver, you can do this:
    callStmt.registerOutParameter(1, OracleTypes.CURSOR);
    ButI failed to find a equivalent in SQL Server 2000 JDBC driver.
    Thanks a lot.

    If you found any solution to this, would you please let me know too? It'll help a tonne.

  • Case sensitive within character literals in SQL Server and Oracle

    I am migrating SQL Server database to Oracle database by using Oracle Workbench.
    SQL Server is not case sensitive, but Oracle PL/SQL is case sensitive within character literals. for example, if sort the following string ('UN','Win', 'iS' ,'Ne','zS'), SQL Server will get ('iS', 'Ne','UN','Win','zS') order, but Oracle PL/SQL will return ('Ne','UN','Win','iS','zS') order.
    Anyone has idea how I can get same result as SQL Server without change PL/SQL code (I don't want to change "ORDER BY typename" to "ORDER BY UPPER(typename)" for every stored procedure).
    Thanks

    Jimmy,
    alter session set NLS_SORT=West_European;
    is the closest thing I know of, but UPPER() is the only sure way.
    West_European sort order is AaBbCc ... 0123456789
    usually sort order is 0123456789 ABC ... abc ...

  • Array data type in SQL server

    Hi there,
    I have stored procedure which does have array data type. recently we have migrated oracle to SQL server
    but this array datatype doesn't support in SQL server.
    How can we rewrite this stored procedure to make it work exactly same as Oracle SP.
    Can you please help on this.
    ALTER PROCEDURE [dbo].[New1]
    @i_ID dbo.t_IdArray READONLY ,
    @i_ArraySize INT ,
    @SWP_Ret_Value FLOAT = NULL OUTPUT
    AS
    Begin
    UPDATE fmm.SITES
    SET DISPLAY_ORDER = id.t_RowNum
    FROM @i_ID id
    JOIN dbo.SITE1 s
    on s.SITE_ID = id.t_ID
    end
    Thanks for your help.

    Hi Latheesh,
    I have tried your bit except configure the SQLCommand and TVP parameter I don't where I need to do this bit.
    Without that bit I have tried your code it was throwing an error like this
    Operand type clash: int is incompatible with t_IdArray
    Can you please have a look .
    Thanks,
    RK
    can you show the definition for  dbo.t_IdArray
    what does it contain?
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Getting a Time value from a datetime data type in SQL Server - URGENT!

    Hi guys
    I have an urgent issue here -
    I have a datetime data type in a SQL Server database. The field holds both a time, and a date within it.
    I am able to pull the date out of the field by using:
    Date sDate = Date();
    while (gd.next()) {
    sDate = gd.getDate(2);
    how do this with the time????
    Thanks

    Hi,
    The funny part here is that you have already done it! The API is a great thing to use to help in your programming.
    API: The class Date represents a specific instant in time, with millisecond precision.
    You want time, you got it! How about:
    sDate.getTime();
    sDate.getMinutes();
    sDate.getHours();
    sDate.getSeconds();
    Not enough?

  • License type of SQL Server 2005 Best Practices Analyzer

    Hi everybody.
    I need to install in my organization the software "SQL Server 2005 Best Practices Analyzer" but I need to know if this application it's free licensing. I have seen on several web sites about this tool it's free but not in official microsoft
    web page. So, where can I find the official microsoft information about the type of licensing of "SQL Server 2005 Best Practices Analyzer" ?
    Thanks of your support

    Hello Erland.
    I followed your advice and I have read the terms of use of this software. I stop at point 3 (which I highlighted). Based on this point, I doubt it is about using this application. Furthermore nowhere says that this software is free to use.
    Would appreciate if someone can clarify this to me.
     =============================================================
    MICROSOFT SOFTWARE LICENSE TERMS
    MICROSOFT SQL SERVER 2005 BEST PRACTICES ANALYZER:
    These license terms are an agreement between Microsoft Corporation (or based on where you live, one of its affiliates) and you. 
    Please read them.  They apply to the software named above, which includes the media on which you received it, if any. 
    The terms also apply to any Microsoft
    *  updates,
    *  supplements,
    *  Internet-based services, and
    *  support services
    for this software, unless other terms accompany those items. 
    If so, those terms apply.
    BY USING THE SOFTWARE, YOU ACCEPT THESE TERMS. 
    IF YOU DO NOT ACCEPT THEM, DO NOT USE THE SOFTWARE.
    If you comply with these license terms, you have the rights below.
    1. 
    INSTALLATION AND USE RIGHTS.  You may install and use any number of copies of the software on your devices.
    2. 
    INTERNET-BASED SERVICES.  Microsoft provides Internet-based services with the software. 
    It may change or cancel them at any time.
    3. 
    SCOPE OF LICENSE.  The software is licensed, not sold. This agreement only gives you some rights to use the software. 
    Microsoft reserves all other rights. 
    Unless applicable law gives you more rights despite this limitation, you may use the software only as expressly permitted in this agreement. 
    In doing so, you must comply with any technical limitations in the software that only allow you to use it in certain ways. 
    You may not
    *  work around any technical limitations in the software;
    *  reverse engineer, decompile or disassemble the software, except and only to the extent that applicable law expressly permits, despite this limitation;
    *  make more copies of the software than specified in this agreement or allowed by applicable law, despite this limitation;
    *  publish the software for others to copy;
    *  rent, lease or lend the software;
    *  transfer the software or this agreement to any third party; or
    *  use the software for commercial software hosting services.
    4. 
    BACKUP COPY.  You may make one backup copy of the software. 
    You may use it only to reinstall the software.
    5. 
    DOCUMENTATION.  Any person that has valid access to your computer or internal network may copy and use the documentation for your internal, reference purposes.
    6. 
    EXPORT RESTRICTIONS.  The software is subject to United States export laws and regulations. 
    You must comply with all domestic and international export laws and regulations that apply to the software. 
    These laws include restrictions on destinations, end users and end use. 
    For additional information, see www.microsoft.com/exporting.
    7. 
    SUPPORT SERVICES.  Because this software is "as is," we may not provide support services for it.
    8. 
    ENTIRE AGREEMENT.  This agreement, and the terms for supplements, updates, Internet-based services and support services that you use, are the entire agreement for the software and support services.
    9. 
    APPLICABLE LAW.
    a.  United States.  If you acquired the software in the United States, Washington state law governs the interpretation of this agreement and applies to claims for breach of it, regardless of conflict of laws principles. 
    The laws of the state where you live govern all other claims, including claims under state consumer protection laws, unfair competition laws, and in tort.
    b.  Outside the United States.  If you acquired the software in any other country, the laws of that country apply.
    10. 
    LEGAL EFFECT.  This agreement describes certain legal rights. 
    You may have other rights under the laws of your country. 
    You may also have rights with respect to the party from whom you acquired the software. 
    This agreement does not change your rights under the laws of your country if the laws of your country do not permit it to do so.
    11. 
    DISCLAIMER OF WARRANTY.  THE SOFTWARE IS LICENSED "AS-IS." 
    YOU BEAR THE RISK OF USING IT.  MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES OR CONDITIONS. 
    YOU MAY HAVE ADDITIONAL CONSUMER RIGHTS UNDER YOUR LOCAL LAWS WHICH THIS AGREEMENT CANNOT CHANGE. 
    TO THE EXTENT PERMITTED UNDER YOUR LOCAL LAWS, MICROSOFT EXCLUDES THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
    12. 
    LIMITATION ON AND EXCLUSION OF REMEDIES AND DAMAGES.  YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U.S. $5.00. 
    YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES.
    This limitation applies to
    *  anything related to the software, services, content (including code) on third party Internet sites, or third party programs; and
    *  claims for breach of contract, breach of warranty, guarantee or condition, strict liability, negligence, or other tort to the extent permitted by applicable law.
    It also applies even if Microsoft knew or should have known about the possibility of the damages. 
    The above limitation or exclusion may not apply to you because your country may not allow the exclusion or limitation of incidental, consequential or other damages.
    Please note: As this software is distributed in Quebec, Canada, some of the clauses in this agreement are provided below in French.

  • Data types in Sql Server 2012 not supported by replication

    Hi All,
    I am planning to configure replication on SQL  server 2012.I need to know what data types are not supported in replication and if there are any other boundations. kindly suggest.
    Regards
    Rahul

    What type of replication are you looking to implement?
    Have you had a look at this thread:
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/bbec1a86-14cd-4d90-8b62-c875de4cf9a0/data-type-not-supported-in-sql-server-2008-merge-replication?forum=sqlreplication

  • How to read varbinary data type using sql server

    Hello,
         I'm converted a text file data into varbinary format, and stored in DB table. Now I need to read
    Varbinary column and store in Temp table
    in sql server.
     can some one help on this.
    Regards,
    Praven
    Regards, Praveen

    I understand this question is related to your previous thread and I believe what Erland suggested is the best way to implement this.
    https://social.msdn.microsoft.com/Forums/en-US/a96a8952-0378-4238-9d9d-85b053182174/send-direct-text-file-as-a-input-parameter-to-sp?forum=transactsql
    I believe when the user uploads the data its getting uploaded onto the Application Server, You could then open the file and import the files into SQL server(all using application code) and do the manipulations. I believe this is the better way of handling
    this.
    Also what is the expected file size and what is the kind of data you are expecting?
    Satheesh
    My Blog | How to ask questions in technical forum

Maybe you are looking for