Invalid data type %.*ls in function %.*ls. is one of the new error messages in SQL Server 2012. This error message is related to PARSE function, a new conversion function shipped with SQL Server 2012.
Let’s discuss this in detail:
Message Number: 10761
Severity : 15
Error Message: Invalid data type %.*ls in function %.*ls.
Error Generation:
Given below is the script that I tried to execute but it resulted with the following error :
SELECT PARSE(GETDATE() AS varchar(11) USING 'en-US') AS Result; --OUTPUT
Msg 10761, Level 15, State 2, Line 1
Invalid data type varchar in function PARSE.
Ooopps…… I am unable to execute it.
Resolution:
In the above example, I tried to parse a datetime into a varchar. First of all, I checked the syntax of PARSE function but the syntax is perfectly fine but the problem is, I used the wrong data type and that datatype is not compatible with the PARSE function.
Here is the list of compatible data types (Numeric & datetime data types) that you can use with this function.
Lets rewrite the above statement with the compatible data types using PARSE function. Given below is the script.
SELECT PARSE('2013-07-12' AS datetime USING 'en-US') AS Result; --OUTPUT
Result
———————–
2013-07-12 00:00:00.000
(1 row(s) affected)
Conclusion :
Whenever you use PARSE function, make sure that you are using the compatible data type (Numeric & datetime data types) in it.