Turkish character problem in select query - SQL Server - sql-server

SELECT [ID]
,[Name]
,[Markup]
,[Status] FROM [dbxyz].[dbo].[Block] WHERE Name = 'Hakkımızda'
Linq2Sql sends this query to SQL Server 2005 but because of the character problem (ı) it does not get the right dataset as a response. No rows returns.
I can not change the collation of database because it is a hosted service and I have no right to do so. I tried to change collation in column level but it did not work.
What can I do?
Thanks

Is the column Block in the database declared with the proper collation? Introduce the Turkish I issue. Note that the collation must be declared even for Unicode Nchars.

I think I'm gonna use ExecuteQuery. ( Bad job! :( )
http://weblogs.asp.net/scottgu/archive/2007/08/27/linq-to-sql-part-8-executing-custom-sql-expressions.aspx

Related

Arabic Language MS ACCESS

I have an ACCESS database in which characters are Arabic but displayed like this "ÇáÓíÏ ÇáÇãíä ÇáÚÇã ááÍßæãÉ" , is there any solution to this problem please? Thanks
This is a collation problem.
ALTER DATABASE (Database name here) COLLATE Arabic_CI_AS ;
All databases have a default collation (which can be set when creating or altering a database. This collation is used for all metadata in the database, as well as the default for all string columns within the database. Users can choose a different collation for any particular column by using the COLLATE clause.
Go here, for further reading.

Inserting arabic characters into sql server database from grails

I have a grails application that is intended to insert arabic characters from interface to sql server database. First I did it with field type varchar but it appears ???????. Then I found that the field type should be nvarchar but with, application simply fails to insert any row by giving the following error,
java.sql.SQLException: Cannot insert the value NULL into column 'id', table 'smsCampaigner.dbo.message'; column does not allow nulls. INSERT fails.
I know that this is constraints error that id cannot be null but this was not the case before changing the field type. Now I want to know whether we can specify fro config.groovy which encoding should be used in database ? any other type of help will be appreciated.
here you go..
when you create the domain class use String type for that column and that's it. you could insert any character it will accept.
for example TestDomain.groovy
class TestDomain {
String column1
}
In mysql you can set up the collation of the database/table/column to use utf8_unicode_ci and if I am not wrong that is valid to save arabic chars. Not sure how to do it with SQL Server but it should be something similar.
Change the collation of the database and tables and columns to Arabic_CI_AS
In Sql Server management studio (SSMS), Execute :
ALTER DATABASE DB06 COLLATE Arabic_CI_AS
where DB06 is the name of the database.
right-click on table, then click design, then select the desired column, in its properties, choose the collation to Arabic_CI_AS
by the way, the error :
Cannot insert the value NULL into column
is not related to Arabic, this is because you are trying to insert NULL in the column that does not allow NULL.

How to Insert korean text in ms-sql server?

I tried to insert korean text into my ms sql server table, but it seems not working properly because all characters are broken like "????" as following:
The type of column is nvarchar, and I query as follow to put the data: insert into mytable values('텍스트'). And the collation is SQL_Latin1_General_CP1_CI_AS, but I wonder if the collation is the problem.
Please help me to find solution
Try this
While working with nvarchar datatype always use N'...'
insert into mytable values(N'텍스트');
This sqlfiddle example shows the difference if you don't use N'...'.
http://sqlfiddle.com/#!6/fab9a/1

CHAR function on SQL Server is returning different values on different servers

When I do
SELECT CHAR(193)
On my local database it returns Á, but when I do the same on a database running on another server it returns ┴.
I expect Á as the correct value, how can I fix the function?
The databases were created individually, they aren't exactly the same.
Try using NChar instead of Char:
SELECT NCHAR(193)
The collation is not the same, run this to see that you get different answers
SELECT CHAR(193) collate SQL_Latin1_General_Cp1256_CI_AS
SELECT CHAR(193)
SELECT CHAR(193) Latin1_General_CI_AS
to find out the collation for the database run this
Select DATABASEPROPERTYEX(DB_name(),'Collation')

Allow special characters SQL Server 2008

I am using SQL Server 2008 express edition and its collation settings are set to default.I wish to store special characeters like á ,â ,ã ,å ,ā ,ă ,ą ,ǻ in my database but it converts them into normal characters like 'a'. How can I stop SQL Server from doing so?
Make sure that your columns are using the type nvarchar(...), rather than varchar(...). The former is Unicode, the latter is ASCII.
Also, make sure that your database default collation is set to Accent Sensitive, and that your columns are stored that way. You may also want to check your instance default collation, as that affects the default collation for your system databases, particularly tempdb.
Rahul, here is a very simple query that runs perfectly on SQL 2005 and 2008:
Query
DECLARE #t1 TABLE (
Col1 nvarchar(30)
)
INSERT INTO #t1 VALUES (N'á ,â ,ã ,å ,ā ,ă ,ą ,ǻ')
SELECT * FROM #t1
Result
Col1
------------------------------
á ,â ,ã ,å ,ā ,ă ,ą ,ǻ
There is nothing special here. No collation change from default, just a simple NVARCHAR column.
You said you are "just running direct queries in the database". Can you try this query and see if you get the same results?

Resources