SQL Server error msg 245
I have recently started getting the following error when I try and execute a view in SQL server:
Msg 245, Level 16, State 1, Line 2
Conversion failed when converting the nvarchar value '<14633>' to data type int.I even get get this when I go to SQL Management Studio and do:
USE [directory-plus]
GO
SELECT * FROM all_staff_data_contact_points I'm not sure what I've done or how to fix this
11 Answer
Your view is trying to convert the string (specifically nvarchar) value of '<14633>' to an int, which it can't do due to the leading and trailing < and > characters.
You need to look at the source code for the view, alongside the data it's fetching and figure out where this conversion is being attempted and correct it by processing the value to "look" like an int (i.e. '14633' - if your field is called NumberString, you could do REPLACE(REPLACE(NumberString,'<',''),'>','')), or stop trying to do the conversion.
If you want a more complete diagnosis, please post the definition of your view (and ideally some example records from the tables it pulls data from).