Reputation: 10981
I'm using the following code:
INSERT INTO tForeignLanguage ([Name]) VALUES ('Араб')
this value inserted like this '????'
How do I insert unicode text from the sql management studio query window?
Upvotes: 46
Views: 89507
Reputation: 2543
Thanks to Ian's answer, you can directly run this code from query window:
declare @FamilyName nvarchar(40)
set @FamilyName = N'嗄嗄嗄'
insert into table(LoginName, Password) select @FamilyName as LoginName, 123 as Password
However, if you wish to perform the above insert through stored procedure, it's needed to attach N
as prefix:
CREATE PROCEDURE Example
@FAMILY_NAME NVARCHAR(40)
AS
BEGIN
SET NOCOUNT ON;
declare @query nvarchar(400);
set @query ='insert into table(LoginName, Password) select N'''+ @FAMILY_NAME +''' as LoginName, 123 as Password';
EXECUTE sp_executesql @query;
END
Hope this helps..
Upvotes: 1
Reputation: 21
The perfect solution with data type limitation:
Basically in MS-SQL Server Amharic text not working properly when the column datatype is 'text'.Therefore to put Amharic text on column with datatype text, first change the text datatype to 'nvarchar(MAX)' or just 'nvarchar' with any char length that MS-SQL Server supported.
Upvotes: 2
Reputation: 294
In my case, the task at hand was to update an SQL table which contains list of countries in two languages in which the local language (Amharic) column was null so executing the following works fine.
Update [tableName] set [columnName] = N'አሜሪካ'
The N in N'አሜሪካ' is the key to put the string as it is in your specific column.
Upvotes: 0
Reputation: 1
Just make datatype NVarchar
in database and following;
internal string InsertUpdate(classname obj)
{
SqlParameter[] sqlparam = new SqlParameter[];
sqlparam[] = new SqlParameter("@DESC1", SqlDbType.NVarChar);
sqlparam[].Value = NullHandler.String(obj.DESC1);
sqlparam[] = new SqlParameter("@DESC2", SqlDbType.NVarChar);
sqlparam[].Value = NullHandler.String(obj.DESC2);
obj.InsertUpdateTable("spname", "sp", sqlparam);
if (sqlparam[].Value != DBNull.Value)
return sqlparam[].Value.ToString();
}
Upvotes: -1
Reputation: 29869
The following should work, N
indicates a "Unicode constant string" in MSSQL:
INSERT INTO tForeignLanguage ([Name]) VALUES (N'Араб')
Upvotes: 114