x
login about faq Site discussion (meta-askssc)

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 '12 at 04:01 PM in Default

hope gravatar image

hope
50 3 4 5

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

2 answers: sort voted first

How about this:

SELECT *
INTO destination_table 
FROM existing_staging_table

You may will use dynamic sql if the destination table name is dynamic.

more ▼

answered Aug 21 '12 at 04:05 PM

eghetto gravatar image

eghetto
1.5k 10 13 19

(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
go
--create table either by CREATE TABLE statement or SELECT INTO
more ▼

answered Aug 21 '12 at 05:05 PM

Kev Riley gravatar image

Kev Riley ♦♦
46.1k 39 43 69

(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.

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x758
x42
x29

asked: Aug 21 '12 at 04:01 PM

Seen: 642 times

Last Updated: Aug 22 '12 at 12:38 PM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.