I\'m trying to solve a problem using t-sql rather than writing a stored procedure to keep things as simple as possible, but at the same time I\'m not sure if it\'s possible