Is this possible?

Code:
IF EXISTS (Select sn_id as snid FROM device.sn WHERE dname_id = 62 and sn_value = '123415')
        BEGIN
        
        SELECT MAX(id) AS maxid FROM device.list 
        
        INSERT INTO parts (sn_id,device_id) VALUES (snid, maxid)
        
        END
ELSE
        BEGIN
          PRINT 'id does not exist'
        return 
        END