Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Server programming

Status
Not open for further replies.

tramck

Instructor
Jul 24, 2002
5
0
0
AU
Hi

I am trying to create a view that holds information as follows:

Basically, each year a new Gl table appears in the database.
The view must:
Select * from GL1
union all
Select * from GL2 (but only if it exists - will appear in database on 1.1.2004)
union all
Select * from GL3(but only if it exists- on 1.1.2005)

I do not want to use a stored procedure as this view is needed to link to other views in a crystal report.

Thanks
 
If a new table only gets added each year then I would just edit the view when you need to add a table. Trying to work out whether tables exist and which ones to include cannot be done in a view (you would have to use a user function) and would be far more complex then adding one line of code once a year. Plus, because you're using a view you wouldn't need to make any changes to your reports.

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top