You have to create the StoredProcedure. Write these code which you have mention in the question and call this storedprocedure in C# code.
It should be some what like this:
CREATE PROCEDURE Procedure_Name
@RNo int,
@SC nvarchar(20)
AS
BEGIN
SET NOCOUNT ON;
IF NOT EXISTS(SELECT * FROM Test
WHERE (@RNo BETWEEN RollNo AND RollNo AND @SC BETWEEN SchoolCode AND SchoolCode))
BEGIN
INSERT INTO Test VALUES (@RNo,@SC)
END
END
GO
Pass values to store procedure from C# code.
Thank You.