0

Long time lurker, first time poster. Working on project for a non-profit group to help migrate queries from an offsite customer relations management (CRM) tool into an EDW. Full disclosure, I love to work with data and know just enough SQL to join data and help reconcile financial data. I am posting today because I think someone with more coding or developing experience can help explain. If not, well then at least I took a shot at becoming SO famous.

There are particular challenges to getting the backend sql code, thus the need for an in-house EDW. The CRM has a gui interface with an SQL generator.

Using the gui interface to generate SQL code delivers results in either an "ad-hoc" or "smart query" format. While not clear on what that really means, it appears the sql code is embedded in an XML like tree format.

My question: what does it mean when I see something like

where table.fieldName = N'someValueToFilter'      

Is that N prefix really doing anything? Based on my exploratory testing it does not. And I've happily moved forward. When I ask around I'm told that it's just smart query logic, and not to worry about it. If I had to guess, I suspect this prefix is a designation to signal that 'someValueToFilter' is a user defined filter from gui. My hope is an independent person will verify my suspicion. Thank you!

jasonMmedina
  • 81
  • 1
  • 6
  • 2
    N just means you can have non-ascii characters... since you only have ascii characters in this constant it has no effect. It effects the type of the string constant not the way the query performs. – Hogan Jan 19 '17 at 02:38
  • see the section of unicode string on this page https://msdn.microsoft.com/en-us/library/ms179899.aspx – Hogan Jan 19 '17 at 02:40
  • It makes a different if the value is in a language that the number of characters are high. The 'N' tells the engine that the string constant is in Unicode. – Sparrow Jan 19 '17 at 02:40
  • Thank you @Hogan for the explanation and documentation. Also appreciate the response from Feryal Badili. I now see the existing question. – jasonMmedina Jan 20 '17 at 22:34

0 Answers0