A run through the idiom, then ...
Take the data:
<root>
<HEADER>
<company_code>GULMOHAR</company_code>
<batch_date>13/01/2011</batch_date>
</HEADER>
<kycdata>
<app_updtflg>01</app_updtflg>
<app_pos_code>GULMOHAR</app_pos_code>
<app_type>I</app_type>
<app_no>00001</app_no>
<app_date>02/01/2012</app_date>
<app_pan_no>ABBDE1234J</app_pan_no>
<app_pan_copy>Y</app_pan_copy>
<app_exmt>N</app_exmt>
<app_exmt_cat />
<app_exmt_id_proof>01</app_exmt_id_proof>
<app_ipv_flag>Y</app_ipv_flag>
<app_ipv_date>13/01/2012</app_ipv_date>
<app_gen>M</app_gen>
<app_name>SANDEEP CHAVAN</app_name>
<app_f_name>HANMANT CHAVAN</app_f_name>
<app_regno />
<app_dob_incorp>05/10/1980</app_dob_incorp>
<app_commence_dt />
<app_nationality>01</app_nationality>
<app_oth_nationality />
<app_filler3 />
</kycdata>
<footer>
<no_of_kyc_records>1</no_of_kyc_records>
<no_of_addldata_records>0</no_of_addldata_records>
</footer>
</root>
Now, imagine that this xml is tablulated in your database and you can query it:
SELECT [idx], [xml_in] FROM [cpqaAnswers].[cpqa].[tblFFIdx]; GO;
Running that query results in a single row of xml and it has an index of datatype [int] equal to "1". Try a hypothetical now:
DECLARE @cC [nvarchar](MAX)
SET @cC = '%<root>%'
DECLARE @cI [int]
SET @cI = 2
(With a slight finnagle, omitting your conditional requirement of the "IF" clause and your first AND, do another query based on the same SELECT -> )
SELECT @cC FROM [cpqaAnswers].[cpqa].[tblFFIdx] WHERE CONVERT([nvarchar](MAX),[xml_in],2) LIKE @cC AND [idx]<>@cI
Your return is:
AVcs
~~~~~~~~
%<root>%
Now try that same query with @cI = 1 (you know this is true for the data, right?)
AVcs
~~~~
You get the empty set. By saying "not 1" the return will say "but there's only 1 ... so nothing". By changing @cC to 2, that "not 1" allows the return of the AVcs string as proscribed.