In a winforms application i 'm storing one Wingdings char in a SQL Server 2005 field of type NVARCHAR(1).
Storing, retrieving and showing up this char in a control works fine.
The problem i'm facing is this: how to search for records which have a specific wingding char value: for example
Select * from table where FieldWithWingding = valueOfLeftArrowChar
How to achieve this?
Thanks in advance
Wingdings is a font! Fonts give a special appearance to characters in a given character set. The left-arrow is therefore a character. Look it up in start->all programs->Accessories->System tools->Character map
Your select will be something like:
Select * from table where FieldWithWingding = 'ß'
Igor pointed me into the correct direction:
it's actually
Select * from table where FieldWithWingding = N'ß'
Works fine!
Thank you everybody!
Try this: select Unicode(N'ß'), Nchar(Unicode(N'ß'))
Use #filter nvarchar(1) or nchar(1) data types
Related
In Snowflake there is a number column storing values like: 8,123,456. I am struggling determining how to structure select statement to return a value like: 00008123456.
In SQL SERVER you can do something like this:
right(replicate('0', 11) + convert(varchar(11), job_no), 11) AS job_no
I understand Snowflake to_varchar function can be used, but not sure how to structure like in SQL Server.
Just add a format string on to_varchar():
select to_varchar(8123456, '00000000000');
Give it try with: lpad(to_char(nos),11,0)
More examples & details: https://docs.snowflake.com/en/sql-reference/functions/lpad.html#examples
a solution provided by Greg Pavlik saved me.
I just switched from DB2 to Snowflake.
So, TO_VARCHAR( <numeric_expr> [, '<format>' ] ) worked.
i am trying to retrieve data from database using Unicode character ₹ with following query
select AnnualSalary,* from UserDetails where AnnualSalary like N'₹%'
I don't understand why this query is not working as normal like query, is there any other way to do this ? please suggest if there is another way
Maybe something like the following will help:
DECLARE #Tab TABLE (ID INT, Salary NVARCHAR(MAX))
INSERT #Tab VALUES (1, N'₹10,000'),(2,N'20,000'),(3,N'30,000'),(4,N'₹50,000')
SELECT ID, CAST(Salary AS nvarchar) Salary
FROM #Tab
WHERE UNICODE(Salary) = UNICODE(N'₹')
hey guys BJones ans is working fine for me and i also found another way and posting here more information
select AnnualSalary,* from UserDetails where CHARINDEX(N'₹', AnnualSalary) > 0
this also gives me the same result as BJones ans give
When you hard-code literals in unicode, you should add the N letter just before the start of the string.
This is non-unicode
'Your string'
This is unicode
N'Your string'
So your like should be
LIKE N'₹%'
select AnnualSalary,* from UserDetails where AnnualSalary like LIKE UNICODE(N'₹%')
Please try this.Its working in SQL Server 2017
you can try below one it will give you correct answer.
select AnnualSalary,* from UserDetails where AnnualSalary like '\U+20B9%';
I have an issue. I have data stored on SQL server with central european characters like "č", "ř", "ž" etc. On the database I have the "Czech_CI_AS" collation which should accepted these characters. But when I try to select for example name of the street with this characters like this:
SELECT *
FROM Street where Name = 'Čáslavská'
It returns me nothing
When I remove the "č" it returns me what I need.
SELECT *
FROM Street where Name like '%áslavská'
I have this column in nvarchar type. But I cannot use the N character before my string because the external applications use this table for read and selects are made automaticlly.
Is here any solution? Or have I got something wrong?
Thanks for any help
#YuriyTsarkov really deservers the credit here. To elaborate on his answer.
From MSDN:
Prefix Unicode character string constants with the letter N. Without the N prefix, the string is converted to the default code page of the database. This default code page may not recognize certain characters.
Example
-- Storing Čáslavská in two vars, with and without N prefix.
DECLARE #Test_001 NVARCHAR(255) = 'Čáslavská' COLLATE Czech_CI_AS;
DECLARE #Test_002 NVARCHAR(255) = N'Čáslavská' COLLATE Czech_CI_AS;
-- Test output.
SELECT
#Test_001 AS T1,
#Test_002 AS T2
;
Returns
T1 T2
Cáslavská Čáslavská
You need to update all your external applications code to use selects with N, or, you need to change collation of your column to same, as used by external applications. It may cause some data loss.
I have a table with one column of CLOB type data, they are all very short no more than 20 bytes, however I cannot see the actual string in the CLOB data.
For example if I use SELECT *, under the CLOB type every data is like:
CLOB, 8 Bytes
CLOB, 15 Bytes
CLOB, 9 Bytes
But I just want to see the content of the CLOB data.
I tried:
SELECT DBMS_LOB.SUBSTR(ClobColumnName, 20 ,1)
And it doesn't work, error is:
Error Code: 4121, SQL State: S1000
Cannot find either column "DBMS_LOB" or the user-defined function or aggregate "DBMS_LOB.SUBSTR", or the name is ambiguous.
So can I ask what's the syntax for direct display a CLOB data in a query?
I'm using SQL Server with dbVisualizer.
I figured out one solution. There should be better ways, please show more possible solutions in the comments.
SELECT CAST(ClobColumnName AS VARCHAR(50)) AS ClobColumnName ;
I have table with one column has CLOB data type(1000K), after storing message/data into CLOB column and found one solution see the actual data in CLOB column.
SELECT CAST(T.CLOB_COLUMNNAME AS VARCHAR(1000)) AS SAMPLEDATA
FROM TABLE_NAME AS T
The above query CAST the CLOB(Character Large Objects) into a normal String.
To see it in DbVis you just have to change it in the options.
There is an entry for the display of CLOB columns.
I presume you are using jDTS driver to connect to the SQL Server.
In the driver properties of the connection you can set the "USELOBS" to False to automatically cast them to string.
I had the same problem and solved it by using DBeaver (http://dbeaver.jkiss.org/) instead of dbVisualizer.
When I use DBeaver and do a select * from my SQLServer I can just double-click the CLOB in the result set and it opens in a new window with the content. Very slick.
I need to insert chinese characters in my database but it always show ???? ..
Example:
Insert this record.
微波室外单元-Apple
Then it became ???
Result:
??????-Apple
I really Need Help...thanks in regard.
I am using MSSQL Server 2008
Make sure you specify a unicode string with a capital N when you insert like:
INSERT INTO Table1 (Col1) SELECT N'微波室外单元-Apple' AS [Col1]
and that Table1 (Col1) is an NVARCHAR data type.
Make sure the column you're inserting to is nchar, nvarchar, or ntext. If you insert a Unicode string into an ANSI column, you really will get question marks in the data.
Also, be careful to check that when you pull the data back out you're not just seeing a client display problem but are actually getting the question marks back:
SELECT Unicode(YourColumn), YourColumn FROM YourTable
Note that the Unicode function returns the code of only the first character in the string.
Once you've determined whether the column is really storing the data correctly, post back and we'll help you more.
Try adding the appropriate languages to your Windows locale setings. you'll have to make sure your development machine is set to display Non-Unicode characters in the appropriate language.
And ofcourse u need to use NVarchar for foreign language feilds
Make sure that you have set an encoding for the database to one that supports these characters. UTF-8 is the de facto encoding as it's ASCII compatible but supports all 1114111 Unicode code points.
SELECT 'UPDATE table SET msg=UNISTR('''||ASCIISTR(msg)||''') WHERE id='''||id||''' FROM table WHERE id= '123344556' ;