I have a bit of code as below, and for some strange reason the actual code issued to SQL server has all of the single quotes replaced with 2x single quotes. Not by my code though. Any thoughts anyone ?
string sql = @"SELECT TOP 1 isnull(rtrim(JCI.joco_FirstName), '''' ) WHERE Case_CaseId = @CaseId;";
using (SqlDataAdapter da = new SqlDataAdapter(sql.ToString(), connection))
Actual SQL issued (via SQL Profiler trace)
exec sp_executesql N'SELECT TOP 1 isnull(rtrim(JCI.joco_FirstName), '''''''' ) WHERE Case_CaseId = @CaseId;',N'@CaseId int',@CaseId=2237361