SQL Server Error 206: Operand type clash

SQL Server error Msg 206, Level 16 is a common error to get when inserting data into a table.

It happens when you’re trying to insert data into a column that is incompatible with the data type you’re trying to insert.

This could happen if you accidentally try to insert data into the wrong column (or even the wrong table). But it could also happen if you incorrectly assume that SQL Server will convert the data for you.

To fix this issue, make sure you’re inserting the correct data type.

Continue reading

How to Fix “Conversion failed when converting the value to data type” in SQL Server

SQL Server error Msg 245, Level 16 tells us that there was a problem when trying to convert a value to a specific data type.

You’ll get this error if you try to insert the wrong data type into a column.

To fix this issue, make sure the data type of the value you’re trying to insert, matches the column’s type.

Continue reading

How to Fix “The select list for the INSERT statement contains fewer items than the insert list”

SQL Server error 120 occurs when you don’t specify enough columns in your INSERT list when using a SELECT list for the values to insert.

To be more specific, it happens when you use a SELECT list in your INSERT statement, but the SELECT list doesn’t return as many columns as you’re specifying with the INSERT.

This is easy to fix. Simply make sure the number of columns match between your INSERT and SELECT list.

Continue reading

How to Fix “ALTER TABLE SWITCH statement failed”

If you’re getting error 4939 while trying to switch a partition in SQL Server, it’s probably because you’re trying to switch to a partition that uses a different filegroup.

One of the requirements of switching partitions is that both the source table or partition, and the target table or partition, must be located in the same filegroup.

Continue reading

SQL Server Error 113: Missing end comment mark ‘*/’

SQL Server error message 113 occurs when you omit a closing comment mark.

This can occur when you open a comment but forget to close it. It can also occur when you accidentally type an opening comment.

There may also be odd occasions where you get this error due to other factors, such as the way your SQL utility handles certain keywords etc.

Continue reading