if
expects a boolean condition - you are returning data.
I assume that you meant that if the item exists, return it, otherwise create it?
If so, then try something like:
IF (NOT EXISTS(SELECT id FROM tbl_ContractNo WHERE Contractno=@Contractno))
INSERT INTO tbl_ContractNo (ContractNo ) VALUES (@ContractNo)
SELECT id FROM tbl_ContractNo WHERE Contractno=@Contractno