sql server - SQL Joining tables based on a list of names -


I am looking for a way to join the series of SQL tables based on the list of table names. The list of table names can change because the system grows but I need to make sure that they work on all the tables in joining.

Each table in the list will have a common column, which is called activityID, in the activity table, back in the foreign key, which is the source table to join.

I could have thought that creating a varchar and creating the query before executing. Is this the best way or can the syntax of joining without the building building be made?

I query a view when you add a new table, to include the new table Change the scene. It will be more efficient than dynamic SQL

If you do not control which / when a table connects, then the following will work in some SQL server like the dynamic SQL:

  Announce @ Select Query NewWorker (maximum) @query = 'Choose from t1' @query = @query + 'left join' + name + 't1. ActivityID = '+ name +'. Activities from the system 'Tables' where '% Activity%' exec (@query) such as  

Again, I wonder what field calling program Hopes


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -