15 April,2016 by Tom Collins
A colleague presented me with the Msg 8116 - Argument data type sql_variant is invalid for argument 1 of function error message when creating a new sql script.
The Msg 8116 error message was generated by executing this code:
select reverse(serverproperty('machinename'))
The REVERSE string function supports return types of VARCHAR or NVARCHAR. SQL Server doesn't not support implicit conversions from sql_variant data to VARCHAR or NVARCHAR. When an attempt is made to implicitly convert from sql_variant data type into VARCHAR or NVARCHAR , the Msg 8116 - Argument data type sql_variant is invalid for argument 1 of function message is returned
A simple fix for the code my colleageue presented is to explicitly CONVERT or CONVERT the sql_variant to a VARCHAR
Implicit conversion of data types in the query engine (SQL Server DBA)
Find column data types using sys.types and sys.syscolumns (SQL ...
SQL Server – large value types out of row and performance (SQL ...
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |