January 28, 2008 at 12:17 pm
Hi,
I have a sql script that returns the value of one query to a table variable (Table A). I then compare this table variable to a physical table (Table B) in my database to retrieve all values in B that are not in A. I am able to see the results via the query analyzer but would like to be able to store these results in a view (for reporting purposes). Unfortunately, I am unable to Create the View (as it must be the first statement in the batch). Secondly, I am using variables that can be only used in the scope of the sql statement that it was created (which means that I cannot reference a declared table variable within scope of a newly created view statement nor use views w/table variables or temp tables). Can anyone recommend a way to store the returned data? Thanks in advance to all responses.
January 28, 2008 at 12:47 pm
Can you combine all the queries into one? Create a view that incorporates both the query for creating TableA and the comparison with tableB? That would give you a 'real-time' view of the differences. If you need a point-in-time snapshot, then you can use global temporary tables (##tablename) or persist it in a real table for the length of time you need it.
Good Luck,
Chad
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply