[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

export/import script

Posted on 2014-08-04
5
Medium Priority
?
201 Views
Last Modified: 2014-08-06
I need to import an excel sheet data (filename.xls) into a sql server db table. I have imported the sheet data into db table named filename#. Now I need to import data in filename# table into table myDestTable (which has an identity PK column.) Due to some column data type differences between the two tables, I have to write a tsql script using
Insert into ...
select ...

Are there any importing scripts samples, especially taking care of data type differences and indetity column, and etc. ?

Thanks.
0
Comment
Question by:minglelinch
  • 2
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
Vikas Garg earned 2000 total points
ID: 40240528
Hi,

Fried there is nothing which can help you except you.

Since the source and destination table must have same data type or you need to cast / Convert according to the destination table datatype.

That is the simplest you can do.

Just check the data type of destination table and convert source data to match up with it
0
 
LVL 1

Author Closing Comment

by:minglelinch
ID: 40241178
Thanks for the post.
0
 
LVL 12

Expert Comment

by:Harish Varghese
ID: 40242969
You may use import wizard in SQL server management studio to take care of data type conversions automatically (wherever possible).
0
 
LVL 1

Author Comment

by:minglelinch
ID: 40243353
I did it this way but failed on conversion.
0
 
LVL 12

Expert Comment

by:Harish Varghese
ID: 40243389
SSIS is the way then. You can have explicit type conversions.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Suggested Courses

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question