Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Adding Columns to derived table vs temp table

Adding Columns to derived table vs temp table

Scheduled Pinned Locked Moved Database
databasevisual-studiohelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MAW30
    wrote on last edited by
    #1

    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

    L S 2 Replies Last reply
    0
    • M MAW30

      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

      L Offline
      L Offline
      loveangel888
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • M MAW30

        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

        S Offline
        S Offline
        SilimSayo
        wrote on last edited by
        #3

        what exactly is the problem? i.e. what are you trying to acomplish?

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups