Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
LexOccam
Starting Member
1 Post |
Posted - 2013-04-15 : 18:08:50
|
I have a simple table with { Name nvarchar(50), ID (int) } columns in an English (EN-Us) database.A tester inserts the following Names: ??, öÄéß, ?e?µI would like to know why a SELECT statement with a WHERE IN clause only yields one result, even though all values are specified as nvarchar. Thank you.Example query:Declare @setOfIds nvarchar(200) = N'''??'',''öÄéß'',''?e?µ'''Declare @strSql nvarchar(1024)Set @strSql = N'SELECT Name, ID from MyTable WHERE Name IN (' + @setOfIds + N')'EXEC (@strSql) |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-04-16 : 00:19:04
|
-- see this illustration... working fineCREATE TABLE Names (name NVARCHAR(100))INSERT INTO NamesSELECT '??'union allSELECT 'öÄéß' union allSELECT '?e?µ'--I would like to know why a SELECT statement with a WHERE IN clause only yields one result, even though all values are specified as nvarchar. Declare @setOfIds nvarchar(200) = N'''??'',''öÄéß'',''?e?µ'''Declare @strSql nvarchar(1024)Set @strSql = N'SELECT Name from Names WHERE Name IN (' + @setOfIds + N')'EXEC (@strSql)/*Output:Name----------------------------------------------------------------------------------------------------??öÄéß?e?µ*/--Chandu |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-04-16 : 02:28:58
|
First check if datatype of Name field is nvarchar------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|