I have two database there is two table both databse how to import data from database table to another database table in sql2008 standard edition. I have tried to export/import function but no luck . would you Please help me ?
INSERT INTO new_table (Foo, Bar, Fizz, Buzz) SELECT Foo, Bar, Fizz, Buzz FROM initial_table -- optionally WHERE ... The INSERT INTO ... SELECT FROM syntax is for when the table you're inserting into ("new_table" in my example above) already exists. As others have said, the SELECT ...
Launch SQL Server Management Studio. Select and right-click on the Source Database, go to Tasks > Export Data. Import/Export Wizard will be opened and click on Next to proceed. Enter the data source, server name and select the authentication method and the source database.
I think the code below will work for your case:
INSERT INTO table1 (column1,column2)
SELECT oldcolumn1, oldcolumn2
FROM table2
Optionally you could add a where clause.
Use this code and check below links
The insert statement actually has a syntax for doing just that. It's a lot easier if you specify the column names rather than selecting "*" though:
INSERT INTO new_table (Foo, Bar, Fizz, Buzz)
SELECT Foo, Bar, Fizz, Buzz
FROM initial_table
-- optionally WHERE ...
The INSERT INTO ... SELECT FROM
syntax is for when the table you're inserting into ("new_table" in my example above) already exists. As others have said, the SELECT ... INTO
syntax is for when you want to create the new table as part of the command.
You didn't specify whether the new table needs to be created as part of the command, so INSERT INTO ... SELECT FROM
should be fine if your destination table already exists.
OR Check this link
i hope this answer useful for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With