March 26, 2014 at 6:39 am
What is mean N'123456 in code below?
Select * from order where orderID=N'123456'
March 26, 2014 at 7:06 am
The N denotes the N(VAR)CHAR type, without it the N it would be (VAR)Char.
😎
March 26, 2014 at 7:15 am
It also means that unless the OrderID column is NVARCHAR, the code isn't SARGable (can't do an INDEX SEEK) and will cause a table scan to do an implicit conversion of all OrderIDs in the table to NVARCHAR because of the high order that NVARCHAR has for data precedence. This is very typical of ORM code and the database normally gets the blame instead of the ORM.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 26, 2014 at 7:23 am
Some users uploaded Access tables to SQL are always NVARCHAR type.
I found that nvarchar cause performace problem. Is it true?
March 26, 2014 at 8:58 am
adonetok (3/26/2014)
Some users uploaded Access tables to SQL are always NVARCHAR type.I found that nvarchar cause performace problem. Is it true?
I don't know why anyone that knew anything about table structure would store what is typically a "digits only" column as NVARCHAR or even VARCHAR. It not only makes for performance problems but causes "row bloat" (a performance, storage, backup, restore, and index problem to name just a few). If real numeric sorts are important, storing such "digit only" data really puts the screws to performance there. The users have made a terrible mistake by doing this themselves instead of working with the DBA on this.
As a side bar, this is why I don't allow users to have anything but read privs (sometimes, write but never DDL privs) in production. They just don't know what they don't know.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 26, 2014 at 11:58 pm
They just don't know what they don't know.
Thats a million dollar quote, Jeff
Bravooo !!!! :hehe:
March 27, 2014 at 2:06 am
twin.devil (3/26/2014)
They just don't know what they don't know.
Thats a million dollar quote, Jeff
Bravooo !!!! :hehe:
You can only achieve wisdom if you know what you don't know. 😉
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply