locked
How to copy a single column data to another table column RRS feed

  • Question

  • User345697035 posted

    How to copy a single column data to another table column

    Saturday, May 21, 2016 10:11 AM

Answers

  • User475983607 posted

    Try this...

    INSERT INTO tb2 (Country)
    SELECT Country 
    FROM tb1 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 21, 2016 10:47 AM
  • User-1636183269 posted

    I will do one correction, assuming that you do want distinct and unique country in another table

    INSERT INTO tb2 (Country)
    SELECT Distinct Country 
    FROM tb1 
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 21, 2016 3:16 PM

All replies

  • User475983607 posted

    You hvea not provided enough context to answer this question.  Is this a SQL question?  .NET?  Explain what you are trying to do and expected results.

    Saturday, May 21, 2016 10:17 AM
  • User345697035 posted

    its a sql server question

    i have a table of country cities and state from which i want only Country column copy to other table

    Saturday, May 21, 2016 10:20 AM
  • User475983607 posted

    its a sql server question

    i have a table of country cities and state from which i want only Country column copy to other table

    You want to copy the country based on what exactly? Does the destination table have data and you need to align the country with the destination records?  Are the tables in the same DB?  Maybe you just need a join.

    The question is still too vague to answer.  Show your DB schema.

    Saturday, May 21, 2016 10:24 AM
  • User345697035 posted

    Actually i have one db name Test there a Two table tbl_newCountries hjaveing column cities, states,Country

    i want to copy the the data Of Country Column to other table in same db 

    Saturday, May 21, 2016 10:29 AM
  • User475983607 posted

    Actually i have one db name Test there a Two table tbl_newCountries hjaveing column cities, states,Country

    Still does not make sense...  You cannot have two tables in the same database with the same name.  Maybe you have two databases?

    Again, post your schema.

    Saturday, May 21, 2016 10:37 AM
  • User345697035 posted

    i have only one database Named Test

    There is one table names tb1 in which there are three colum Citis, State,Country

    i want to copy the data of tb1  Country Column 

    to my table tb2 Column name CountryName

    Saturday, May 21, 2016 10:42 AM
  • User475983607 posted

    Try this...

    INSERT INTO tb2 (Country)
    SELECT Country 
    FROM tb1 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 21, 2016 10:47 AM
  • User345697035 posted

    ok thank-You

    Saturday, May 21, 2016 11:23 AM
  • User-1636183269 posted

    I will do one correction, assuming that you do want distinct and unique country in another table

    INSERT INTO tb2 (Country)
    SELECT Distinct Country 
    FROM tb1 
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 21, 2016 3:16 PM