SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Flat File Source -> DB table overwrite in T-SQL 2008R2


Flat File Source -> DB table overwrite in T-SQL 2008R2

Author
Message
Ryan1
Ryan1
SSC-Enthusiastic
SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)

Group: General Forum Members
Points: 189 Visits: 130
Hello SQLSC,

I am extremely new to SQL. As you can tell is my first post on the forum, I have a feeling we are going to get to know each other very well ;-)

I have been tasked to use a flat file source -> overwrite a table on a 2008R2 SQL database with the data in the flat file source. I am able to utilize BIDS to create a new table in which my data can upload to no problem. I cannot however overwrite the table that it needs to go. It seems to run in bids no problem with no errors. Any detailed help would be much appreciated.

Thank you and have a nice day.
Elliott Whitlow
Elliott Whitlow
SSC-Insane
SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)

Group: General Forum Members
Points: 23984 Visits: 5314
Not entirely clear what the issue is..

In your process are you needing to drop the table then load it? Or do you just need to clear the table? Please go into additional detail.

CEWII
Ryan1
Ryan1
SSC-Enthusiastic
SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)

Group: General Forum Members
Points: 189 Visits: 130
The flat file data needs to replace the data in the columns of the database table.
The table in the database has column names that the flat file does not as well.
Elliott Whitlow
Elliott Whitlow
SSC-Insane
SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)

Group: General Forum Members
Points: 23984 Visits: 5314
Ok, so I read that as you need to empty the destination table.

On the Control Flow of the SSIS package add a Execute SQL Task, chose the correct connection, and put in a TRUNCATE TABLE command for the table you need to empty, connect the Exec SQL task to the Data-Flow task and you should be in good shape.

CEWII
Ryan1
Ryan1
SSC-Enthusiastic
SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)

Group: General Forum Members
Points: 189 Visits: 130
Thank you so much Elliot!!
Ryan1
Ryan1
SSC-Enthusiastic
SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)

Group: General Forum Members
Points: 189 Visits: 130
Is there any way to fully map each Available Input Column to each Available Output Column in the OLE DB Destination Editor without dragging each column name across, making a link?
Elliott Whitlow
Elliott Whitlow
SSC-Insane
SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)

Group: General Forum Members
Points: 23984 Visits: 5314
You are very welcome, this is a VERY common design pattern, clean the receiver, fill the receiver, then run some process to do something with the data..

CEWII
Elliott Whitlow
Elliott Whitlow
SSC-Insane
SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)

Group: General Forum Members
Points: 23984 Visits: 5314
If they have the same names they will usually automap, but if they don't then no, you have to handle the mapping.

CEWII
Ryan1
Ryan1
SSC-Enthusiastic
SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)

Group: General Forum Members
Points: 189 Visits: 130
Awesome, thank you so much.
Ryan1
Ryan1
SSC-Enthusiastic
SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)

Group: General Forum Members
Points: 189 Visits: 130
Are there ways for me to replace the flat source file name and database table name with variables?

-I started with the Execute SQL task in control flow, trying to use a variable for a table name in that area first.
-Trying to piece together information on how to accomplish this from different websites, but I have hit a stand still.
*listed attachments display print screens of my settings.


1.
The 'value' of my 'execute' variable is:

TRUNCATE TABLE [nevada].[dbo]@tableName;
----------
2.
My ResultSetType is set to: ResultSetType_None
-----------
3.
Resulting Error when debugging:
[Execute SQL Task] Error: Executing the query "TRUNCATE TABLE [nevada].[dbo]@tableName;" failed with the following error: "Parameter name is unrecognized.". Possible failure reasons: Problems with the query"ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

-Parameter Name is 0
-ResultSet is greyed out in 'edit' of Execute Sql Task
-Connection is established, package runs fine when my new variables are not in place.


Thank you.
Attachments
Variable1.jpg (9 views, 152.00 KB)
Variable 2.jpg (6 views, 76.00 KB)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search