Implicit conversion of varchar value to varchar cannot be performed because the collation of the value is unresolved due to a collation conflict.

Problem:

I am trying to validate the codes in "Script to auto generate a security report for your SQL Server instance" by  on SQL Server 2008R2, I get an error:

Implicit conversion of varchar value to varchar cannot be performed because the collation of the value is unresolved due to a collation conflict.

Reason:

My server has a collation: Latin1_General_CI_AS
The Database context runs the code has a collation: Latin1_General_CP1_CI_AS

That causes the problem.

Solution:

Run the following code to make the DB collation in sync with the server collation. After that, it works!

USE Tempdb
GO

ALTER DATABASE (database name here) COLLATE (collation name here)
GO