July 28, 2005 at 8:17 am
Is there some reason to prefix string fields with an N?
I.E.:
select * from sysobjects
where OBJECTPROPERTY(id, N'IsProcedure') = 1
order by name
returns the same as:
select * from sysobjects
where OBJECTPROPERTY(id, 'IsProcedure') = 1
order by name
which is better and why?
In advance, thanks for you help
Pete
July 28, 2005 at 8:26 am
The N is just a way to tell SQL that the string is a UNICODE string object names in sysobjects are represented in nvarchar(128) (sysname) On systems where the collation can be anything this becomes important (Chinese, Kiri, etc)
hope this helps
* Noel
July 28, 2005 at 11:21 am
Also, some system procedures like sp_executesql call for nvarchar parameters. If you're a neat freak like me, you define your variables and constants as nvarchar so there aren't 47 automatic conversions going on behind the scenes from varchar to nvarchar. Performance-wise, it probably doesn't make a difference, but it FEELS better to do it that way. 8{)
July 29, 2005 at 2:10 am
If you prefix with n (Unicode), you are using two-byte characters, so you are limited to field widths of 4030 characters instead of 8060 (assuming a single field table!) and wasting space. Only do it if you really need to.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply