x

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

avatar image

hope
50 4 6 8

(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, 2012 at 04:05 PM

avatar image

eghetto
2.1k 18 23 31

(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, 2012 at 05:05 PM

avatar image

Kev Riley ♦♦
64.2k 48 62 81

(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

SQL Server Central

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

Topics:

x1154
x44
x39

asked: Aug 21, 2012 at 04:01 PM

Seen: 1888 times

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

Copyright 2016 Redgate Software. Privacy Policy