Passing table to a function in SQL Server