SET keyword in SQL Server
Multiple values shouldn't be assigned to a scalar variable. It makes no sense

You need a table variable (or temporary table). 

Declare @StudentName TABLE (sname Nvarchar(max));
INSERT @StudentName (sname) VALUES ('ABC'),('DEF'),('PQR'),('XYZ');


You can JOIN etc to this as you would a normal table. Or use it in an IN clause

WHERE
    X.SomeCol IN (SELECT sname FROM @StudentName)


Edit, after comments

INSERT @StudentName (sname) 
SELECT ... -- the other query here