Rahul,
I need to see your table definitions to be sure, but it sounds like your tables are defined with different collations. Or that is to say that your table and your function have different collations.
Here is an illustrative example of how to resolve collation conflicts:
USE Tempdb
SET NOCOUNT ON
CREATE TABLE dbo.DemoCollationSorting
(vchLATCIDict varchar(3) COLLATE Latin1_General_CI_AS
,vchLATCSDict varchar(3) COLLATE Latin1_General_CS_AS
,vchLATBIN varchar(3) COLLATE Latin1_General_BIN
)
INSERT dbo.DemoCollationSorting VALUES ('ZZZ','ZZZ','ZZZ')
INSERT dbo.DemoCollationSorting VALUES ('zzz','zzz','zzz')
INSERT dbo.DemoCollationSorting VALUES ('aaa','aaa','aaa')
INSERT dbo.DemoCollationSorting VALUES ('AAA','AAA','AAA')
INSERT dbo.DemoCollationSorting VALUES ('MMM','MMM','MMM')
INSERT dbo.DemoCollationSorting VALUES ('mmm','mmm','mmm')
-- Gives the
--Msg 468, Level 16, State 9, Line 2
--Cannot resolve the collation conflict between "Latin1_General_CS_AS" and "Latin1_General_CI_AS" in the like operation.
EXEC('
SELECT *
FROM dbo.DemoCollationSorting
WHERE vchLATCIDict Like vchLATCSDict
')
-- This works
SELECT *
FROM dbo.DemoCollationSorting
WHERE vchLATCIDict COLLATE Latin1_General_CS_AS Like vchLATCSDict
David Lundell
Principal Consultant and Trainer
www.mutuallybeneficial.com