Sql-server – How tomport table from an ODBC Database

odbcsql serversqlbulkcopy

I have an ODBC Database (some third party DB) where I have a bunch of tables. I am able to use 'GetSchema' to get a list of tables in there. I am also abe to utilize SQLBulkCopy to copy Data from these tables to SQL Server tables (only when I have created a Destination table with the same structure in SQL Server).

But here is the scenario – an update was applied to the ODBC database and now it has a new table (I am able to figure that out via comparing Old & new list of tables in ODBC database.

Is there a way to either Import the entire table (empty or with Data) OR Generate SQL script for the Source table so that Destination table can be created before using Bulk Copy operation ?

thanks
RD

Best Answer

Why don't you use the import/export wizard? You can access it by right-clicking on a database in SSMS, and selecting Tasks > Import Data.

On the "Select Source Tables and Views" page, click "Edit Mappings" and "Edit SQL", if you only want the CREATE TABLE SQL, otherwise you can use the wizard to perform the import as well.