Solve scheme MS SQL query issue