How to load data dynamically using ssis

Sorry, I didn't frame my question properly. I updated my question. I am trying to automate a process using SSIS where

1)A csv file comes from some database into a folder. (completed)

2) My etl recognizes the file and creates a staging table in the Database converting all data into nvarchar(MAX). (completed)

3) Insert data from staging to destination table and if it does not exist then create a table and insert the data into it. (issue)

more ▼

asked Aug 21, 2012 at 04:01 PM in Default

hope gravatar image

50 4 4 5

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

How about this:

INTO destination_table 
FROM existing_staging_table
You may will use dynamic sql if the destination table name is dynamic.
more ▼

answered Aug 21, 2012 at 04:05 PM

eghetto gravatar image

2.1k 16 18 24

(comments are locked)
10|1200 characters needed characters left

If the table is dynamic, i.e. it changes, then you should always be creating the table when you need it, so I would check for it's existence, delete it if necessary and then recreate it

if object_id('YourStagingTable','U') is not null drop table YourStagingTable
--create table either by CREATE TABLE statement or SELECT INTO
more ▼

answered Aug 21, 2012 at 05:05 PM

Kev Riley gravatar image

Kev Riley ♦♦
53.8k 47 49 76

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Aug 21, 2012 at 04:01 PM

Seen: 1561 times

Last Updated: Aug 22, 2012 at 12:38 PM