Check 2 tables(Table A and Table B) and figure out new columns present in Table A and add these new columns to Table B

How to check 2 tables(Table A and Table B) and figure out new columns present in Table A and add these new columns to Table b.
DDL-
Create table A
( A INT,
B INT,C VARCHAR(2)
Create table B
A INT,
B INT
Any advice on the best approach or method to achieve this.
I understand that I need to check the schema of the columns and then do a match between 2 tables and find new columns and then alter my target table
Mudassar

Can you try this..
CREATE TABLE A ( A INT, B INT, C VARCHAR(2) )
CREATE TABLE B ( A INT, B INT )
Declare @ColumnVar nvarchar(128),@DatatypeVar nvarchar(128)
SELECT @ColumnVar=x.COLUMN_NAME, @DatatypeVar=x.DATA_TYPE
FROM INFORMATION_SCHEMA.COLUMNS AS x
WHERE TABLE_NAME = 'A'
AND NOT EXISTS ( SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'B'
AND COLUMN_NAME = x.COLUMN_NAME )
Declare @SQL VarChar(1000)
SELECT @SQL = 'ALTER TABLE B ADD ' + @ColumnVar + ' '+ @DatatypeVar
Exec (@SQL)
select * from B
Please Mark This As Answer if it helps to solve the issue
http://stackoverflow.com/questions/2614101/alter-table-my-table-add-column-int

Similar Messages

  • I reformated my computer to sell and now I cannot figure out how to find the system info and specs of the computer

    I had Apple wipe my computer clean and now it's at the "Welcome" page but I need to find out all the specs like RAM/Hardrive space how can I get that info without running the welcome intro?

    if you know the year and CPU speed of this macbook - go to everymac.com and match your specs from the year it was released.
    if you can see your serial number - go to the link below and enter the last 3 characters of your serial number and you'll get the specs.
    http://www.everymac.com/ultimate-mac-lookup/

  • I have a Verizon IPhone 4 and i can't figure out how to get my ringtones from an app to my iTunes account, it doesn't have a tab for Ringtones! I have tried unplugging it and checking if would show up but it didn't, how do you enable the ringtone folder?

    I have a verizon IPhone and i can't figure out how to get my ringtones from the app to iTunes, my account doesn't have a ringtone section in the liRingtone Folder?brary, how do you enable the ringtone folder?

    Edit > Preferences.  Select the check box for Ringtones, this will add them to the listing in iTunes. 
    Not sure that really answers your question though.

  • HT1657 I rented a movie and accidentally hit the menu button and now I can figure out how to go back and watch it . When I try to press rent again it says you have already downloaded this movie go to settings and check for downloads but I can find it.

    I rented a movie and accidentally hit the menu button and now I can figure out how to go back and watch it . When I try to press rent again it says you have already downloaded this movie go to settings and check for downloads but I can find it download in settings.

    I had the same issue with my apple tv 3rd generation. I rented Sinister and selected the "rent and watch now" option. Half way through the movie I accidentally pressed the menu button. When I looked for the rented movie on my apple tv I could not find it. Not even above the movie pannel where "purchased" and "top movies" comes up on the main menu. the apple tv suggests to go to settings>downloads but I don't have that option. I did go to settings> itunes store> check rentals but that didnt work either. It took too long to even check. Thank you because this SOLUTION worked great.
    SOLUTION: How to reset apple tv 3 3rd generation to view rented movies:on the apple tv remote: press and hold "menu" to go to the main menu. Select SETTINGS> GENERAL >RESET >RESET ALL SETTINGS. After the apple tv resets, input all your information again and your rented movies should be visible when you cruise above the "movies" section. THANK YOU!!
    Apple needs to solve this issue because honestly it took me 3 hours and a half to watch a movie that only lasted 2 BECAUSE I wast trying to solve the issue, reseting and all. blahh.

  • One day it just stopped focusing and the pictures are blurry.  If I switch it to the front camera it works well and looks like it should but when I turn it back it goes back to being out of focus and I can't figure out how to fix it?

    i installed ios 7.after  that my primary cam, one day it just stopped focusing and the pictures are blurry.  If I switch it to the front camera it works well and looks like it should but when I turn it back it goes back to being out of focus and I can't figure out how to fix it?

    This advice will sound like a joke or prank, but believe me it worked on my iPhone 5 and my daughter's.  The lens mechanism got stock on each of our iPhones.  We found a post on these message boards that said to hold the iPhone about 6 inches above a table or counter top and drop it so that it lands flat on it's back.  Now try the camera ...Fixed!  It has been more than six months now and neither of our iPhones have ever experienced the problem again. 

  • My podcast isn't updating and I can't figure out why, please help?

    Hi everyone,
    I'm at my wits end and I can't figure out what's wrong with my podcast in regards to iTunes.
    We have a website we update that originally iTunes was pointed at (http://www.whydaddydrinks.net/?feed=rss2) and then iTunes started having issues with not updating. Recently we tried changing the feed of the podcast to the RSS feed for our podcast hosting account at Podbean (http://whydaddydrinks.podbean.com/feed/) and it's running into the same issue.
    I've checked FeedValidator for both feeds and they're fine (http://feedvalidator.org/check.cgi?url=http%3A%2F%2Fwww.whydaddydrinks.net%2F%3F feed%3Drss2 and http://feedvalidator.org/check.cgi?url=http%3A%2F%2Fwhydaddydrinks.podbean.com%2 Ffeed%2F). I've clicked the links to the .mp3 files and they play off the web, so, in theory, there shouldn't be any issue as far as I know; Episode 13 shows up in iTunes but dosn't appear to be connected to the file and Season 2 Episode 1 doesn't show up at all.
    Can any of you offer any suggestions as to what the heck is going on?

    Your Store page is at https://itunes.apple.com/gb/podcast/your-book-is-why-daddy-drinks/id515363310?mt =2
    This is using the feed at http://www.whydaddydrinks.net/?feed=rss2 so the other feed URL you posted is irrelevant.
    This feed has episodes up to 13 which contain playable media, and these all show in the Store and when subscribing. However the URL for the media file for episode 13 is
    http://media40.podbean.com/pb/89ea6f327345e33833ff09885e48b8a1/50e904db/data2/bl ogs48/462271/uploads/YBIWDD_Episode13.mp3
    and there is no file at this address. The previous episode downloads OK.
    This feed contains two later episodes but neither has an 'enclosure' tag containing the URL of a media file and so the episodes don't show in iTunes. You are using WordPress to make your feed, and this problem arises a lot - it presumably means that you have failed to do something you need to do in WordPress to get the media file into the feed, but I can't advise on specifics of WordPress.
    The other feed has one of these two episodes, and there the latest episode does have an 'enclosure' tag and the episode appears when subscribing manually; however as I say this feed is not in use by the Store.
    So you need to do with the original feed whatever it was you did with the new feed to get the episode into the Store, and you need to chase the missing media file for episode 13.
    If you want to move the Store to using the Podbean feed you need to follow the procedure outlined here:
    http://www.wilmut.webspace.virginmedia.com/notes/podcast.html#move
    Note that the title in the Podbean feed is 'whydaddydrinks' which many not be what you want.

  • HT1657 I rented a movie and now I cannot figure out how to watch it on Apple TV.  We did the update yesterday.  I used to go under the "Movies" tab and click Play.  It has the original options now and when I click "Rent" it says already rented, not downlo

    I rented a movie from ITunes yesterday and now I cannot figure out how to watch it on Apple TV.  I have done this before, and to watch it later on, I would go back under the "Movies" option, find the movie, and there would be a Play option available.  We did the update to Apple TV yesterday.  Now when I go back to the movie, I see the original options. Preview, Rent, Buy, etc.  When I click on Rent again, it says the movie has already been rented but not downloaded. It instructs me to go under Settings/Downloads/Check Downloads, but there is nothing under Settings about Downloads.  I found an option to Check for Rentals, but when I click on that option, it just keeps searching, with no results.  Any ideas?  This worked before the update, even though it took forever to download a movie....

    I had the same issue with my apple tv 3rd generation. I rented Sinister and selected the "rent and watch now" option. Half way through the movie I accidentally pressed the menu button. When I looked for the rented movie on my apple tv I could not find it. Not even above the movie pannel where "purchased" and "top movies" comes up on the main menu. the apple tv suggests to go to settings>downloads but I don't have that option. I did go to settings> itunes store> check rentals but that didnt work either. It took too long to even check. Thank you because this SOLUTION worked great.
    SOLUTION: How to reset apple tv 3 3rd generation to view rented movies:on the apple tv remote: press and hold "menu" to go to the main menu. Select SETTINGS> GENERAL >RESET >RESET ALL SETTINGS. After the apple tv resets, input all your information again and your rented movies should be visible when you cruise above the "movies" section. THANK YOU!!
    Apple needs to solve this issue because honestly it took me 3 hours and a half to watch a movie that only lasted 2 BECAUSE I wast trying to solve the issue, reseting and all. blahh.

  • I am moving from Southern California to Maui, Hawaii and I need to figure out the best way to get my 24 inch iMac across the ocean. Does anyone know the best way to do this?

    I am moving from Southern California to Maui, Hawaii and I need to figure out the best way to get my 24 inch iMac across the ocean. Does anyone know the best way to do this? I have found GearGrip's LCD harness so that I can do carry-on onto the plane...  Or maybe use a Pelican Case to do it as a "checked bag"? Or any other suggestions??! Please help!
    Thanks so much!!

    I don't recommend you send the iMac in a checked bag. Might get damaged.
    Check the airlines website for carry on guidelines.
    Or, if you have the original box that the iMac came in, if you have someone who can pick up the iMac for you, send it ahead Fed Ex and insure the package.
    Just make sure the display is covered to protect it. A blanket perhaps.
    Aloha ...

  • Random music is playing and we can't figure out where it is coming from, random music is playing and we can't figure out where it is coming from

    ONe of our Macs has just randomly started playing music and we can't figure out where it is.  iTunes is off, all browsers are off.  Anyone know how to search for the source??

    Have you got iChat.   There have been examples where this was the cause.  If you have, turn it off to check.   You could also go to activity monitor to check what parts of you system are active.

  • Since upgrading to mavericks, my email autofill is incorrect and I can't figure out how to fix it.

    Since upgrading to mavericks, my email autofill in Safari is incorrect and I can't figure out how to change it.  I start typing my email [email protected] on a website and that I need to put my email in (like to request a newsletter etc).  As soon as I get to the @ it fills it in as [email protected]@.  It is baffling and frustrating. Any ideas?  Autofill in general, for all my info (adress etc) works fine.

    Hi srd9196,
    Thanks for using Apple Support Communities.  I would check for a substitution being set in System Preferences -> Keyboard -> Text:
    OS X Mavericks: Text pane of Keyboard preferences
    http://support.apple.com/kb/PH14226
    Cheers,
    - Ari

  • I have a 2nd generation Ipod. I have it connected to my computer and see (my name) ipod on my screen. Everytime I try to add a new song to the Ipod, this message comes up and I am not sure what to do:   The Ipod, (my name) is synced with another ITunes li

    I have a 2nd generation Ipod.
    I have it connected to my computer and see (my name) ipod on my screen.
    Everytime I try to add a new song to the Ipod, this message comes up and I am not sure what to do:
    The Ipod, (my name) is synced with another ITunes library on A74F65. Do you want to erase this Ipod and sync with this ITunes Library?
    An Ipod can be synced with only one ITunes library at a time.  Erasing and syncing replaces the contents of this IPod with the contents of this ITunes library.
    Then it asks me if I want to delete and sync.
    I am not sure what to do for fear of erasing everything I have put on my Ipod.
    I would appreciate if someone could help me out. 

    If I understand you correctly, you are trying to use iTunes to play the Music in your iPod but which is not in your itunes library. I don't think Apple design iTunes for use in your way. As to put and play music in iPod, the music has to be in iTunes first, so you play music in the iTunes music Library. the window with Ipod music is just to show you which music are already in the Ipod, in case you want to Manually Manage your huge music library.
    Here is the iPod/iTunes manual from the Apple Support Site.
    http://manuals.info.apple.com/en_US/iPod_Features_Guide.pdf
    Have A NICE DAY!

  • I can't seem to sync my contact on my ipad.  the contact list is a book type and I can't figure out how to use it

    I can't seem to sync my contact on my ipad.  the contact list is a book type and I can't figure out how to use it

    Look at Chapter 13 of the iPad iOS4.3 User Guide

  • My lifetime calls is glitched at 4,924,000,000 and I can not figure out how to reset this PLEASE HELP URGENTLY I don't know how to resolve this

    My IPhones total life time calls is at 4,924,000,00 and I can't figure out if this is a glitch because I know that I have DEFIANTLY not called for that long I don't know if this will be resolved but someone PLEASE HELP

    Glad it helped!
    For what it's worth, I suspect you'd have to restore the phone as new to resolve the issue. If it were mine, I'd probably elect to live with the weirdness rather than go through the fuss of a restore.
    Best of luck.

  • I'm staying at my house in Peru, South America. From my PC laptop I can see my neighbor's wifi service network, but I also have my mini iPad and I can not figure out why I can't get any wifi connection from my area. Is there a setting I need to do?

    I'm staying at my house in Peru, South America. From my PC laptop I can see my neighbor's wifi service network, but I also have my mini iPad and I can not figure out why I can't get any wifi connection from my area. Is there a setting I need to do?

    Yes, I did try to go on my settings>wifi and was waiting for any wifi signals to pick up, but nothing shows up. But on my PC I get a whole list of networks to choose from. Regarding my neighbor, I already have her password that is why I was able to get it on my PC, the problem is that the mini Ipad is not picking any signal neither can it locate me when I go to maps.

  • I recieved an Adobe Master Collection License number from my school (Stevens Institute of Technology) and I can't figure out how to use it in order to get the product. I've created a username and that's as far as I've gotten.

    I recieved an Adobe Master Collection License number from my school (Stevens Institute of Technology) and I can't figure out how to use it in order to get the product. I've created a username and that's as far as I've gotten. I need to download the product and I can't figure out where to begin.

    Ask someone at your school... Do you have a Cloud redemption code, or a CS6 serial number?
    If Cloud, Redemption Code http://helpx.adobe.com/x-productkb/global/redemption-code-help.html and
    http://www.adobe.com/products/creativecloud/faq.html
    http://helpx.adobe.com/creative-cloud/help/install-apps.html to install or uninstall
    http://forums.adobe.com/community/download_install_setup/creative_cloud_faq
    What it is http://helpx.adobe.com/creative-cloud/help/creative-cloud-desktop.html
    Cloud Getting Started https://helpx.adobe.com/creative-cloud.html
    If CS6, download at Other downloads and enter your serial number when prompted
    Again... your 1st resource is your school

Maybe you are looking for