Adding Columns to derived table vs temp table
-
Can I make a derived table with a name for all then an alias column names for each of the three unions SELECT A.strName FROM ( SELECT strName FROM [dbo].[Summary] UNION SELECT strName FROM [dbo].[Summary_Old] UNION SELECT [TABLE_NAME] FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' ) AS A So it will look as follows: strName, strName1, strName2, strName3, strCompare All names will fall into strName then only names in the first table will fall into strName1 etc. Then I would like to compare these names in a fifth column strCompare to add, delete, NA so I can synchronize tables and database the Table Names are a reference for all tables in the DB to strNames or should I set the names into a temp table then add columns and compare How would I do the above either in derived or temp Any help is appreciated Thanks in advance, Michael
-
Can I make a derived table with a name for all then an alias column names for each of the three unions SELECT A.strName FROM ( SELECT strName FROM [dbo].[Summary] UNION SELECT strName FROM [dbo].[Summary_Old] UNION SELECT [TABLE_NAME] FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' ) AS A So it will look as follows: strName, strName1, strName2, strName3, strCompare All names will fall into strName then only names in the first table will fall into strName1 etc. Then I would like to compare these names in a fifth column strCompare to add, delete, NA so I can synchronize tables and database the Table Names are a reference for all tables in the DB to strNames or should I set the names into a temp table then add columns and compare How would I do the above either in derived or temp Any help is appreciated Thanks in advance, Michael
I'm not sure about the fifth column but the strName1, strName2, strName3, can be made by using the great and magnificent left outer join operation.
-
Can I make a derived table with a name for all then an alias column names for each of the three unions SELECT A.strName FROM ( SELECT strName FROM [dbo].[Summary] UNION SELECT strName FROM [dbo].[Summary_Old] UNION SELECT [TABLE_NAME] FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' ) AS A So it will look as follows: strName, strName1, strName2, strName3, strCompare All names will fall into strName then only names in the first table will fall into strName1 etc. Then I would like to compare these names in a fifth column strCompare to add, delete, NA so I can synchronize tables and database the Table Names are a reference for all tables in the DB to strNames or should I set the names into a temp table then add columns and compare How would I do the above either in derived or temp Any help is appreciated Thanks in advance, Michael