• Nothing like getting thrown into the fire. Welcome. We try to help out here as best we can.

    From the sounds of it, no constraints especially, you're going to be dealing with quite a lot. I'd suggest reconfiguring and going from the basics. Instead of trying to use a table valued function, just incorporate this into your existing query (I'm assuming you're trying to add this to a query). Either just join to the tables you're interested in and then filter based on the dates, or use this as a derived table.

    From what you typed, it sounds like this is part of a greater query. We could help you more if we knew what the greater query looked like.

    Again, welcome to the party. Once the fear and trepidation wear off, it's fun.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning