NVARCHAR not recognized built-in function name

Posted on 2014-07-24
Last Modified: 2014-07-24
I'm writing some code that is from a lesson.  I've added a field to a table as xml.  In VS2010, I run my app and the gridview doesn't show up, it does throw and error and it seems to be in SQL.  I'm trying to show the data as nvarchar.  Here's the select statement used.

SELECT id, date_added, comment, application_name,extra_data.value('(/data/@username)[1]', nvarchar(100)) as username FROM ApplicationLog WHERE Application_Name = @appname

I haven't been able to find anything that talks about what is needed to fix it.  I'm just learning the development aspect of things here at work.  Help is greatly appreciated.  Thanks
Question by:Sherry
LVL 22

Accepted Solution

Snarf0001 earned 250 total points
ID: 40218278
You have to wrap the datatype in single quotes as well (passing it as a string):

SELECT id, date_added, comment, application_name,extra_data.value('(/data/@username)[1]', 'nvarchar(100)') as username FROM ApplicationLog WHERE Application_Name = @appname

Author Closing Comment

ID: 40218292
Perfect, thank you.  I thought it would be something simple like that.

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now