Follow sqlserver-dba.com

Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions

SQLServer-DBA.com Links

Dba_db2_button

dba-ninja.com

SQL Server DBA Jobs

Msg 8116 - Argument data type sql_variant is invalid for argument 1 of function

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

 

Read More on Data types

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 ...

 

 


Author: Tom Collins (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

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.

Working...

Post a comment on Msg 8116 - Argument data type sql_variant is invalid for argument 1 of function


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer