Passing a Table as a Parameter

  • I want to create a series of temporary tables of identical structure, perform the same processing on each, and then insert the combined results into one super-table for display. To do the 'same processing' on each one, I need to pass each table to a subroutine of some sort (stored proc? UD function?) and get the enhanced table returned.

    This could be done by passing a cursor to a stored proc, but the processing involved is set-based, e.g. summing one column, so this would be wasteful of processing time and inelegant.

    A table-valued function could return a table but it can't be passed one as everything else has to be defined locally.

    Any ideas out there?

  • Why not simply create one temp table with the same structure, then add an InstanceId column to it? This column could be 1 for data in the first temp table, 2 for data in the second and so on.

  • I've spent so much time looking for complicated solutions, ... as far as this piece of work goes, I think that will probably do the trick! Thanks a lot.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply