Hardcode the column values using SSIS
-
Tuesday, June 12, 2012 9:43 PM
Hi,
I have a couple of tables in my database. One of them has 7 columns and the other has 16 columns. The data types and columns match for the 7 columns of table1 and hence per my requirement I need to move the values of the 7 columns of table1 to table2. But for the other 9 columns in table2 I need to hardcode them. Can someone point me to right direction on how to get this done?
Thanks much for help in advance.
All Replies
-
Tuesday, June 12, 2012 10:04 PMDoes each of the 9 columns require a different value for each row?
Carla Sabotta
-
Wednesday, June 13, 2012 12:33 AM
Hi,
you don't need to map all columns to the destination just map your desire columns to the appropriate columns of table. as you can see in the following snapshot that only related attributes are map and remains are un mapped.
thanks,
Zaim Raza.
-
Wednesday, June 13, 2012 2:54 AM
Does each of the 9 columns require a different value for each row?
Yes Carla.
Carla Sabotta
-
Wednesday, June 13, 2012 2:59 AM
That works well. But I want to assign hardcoded values to the other columns. All the columns a unique value. And these unique values will be used through out the rows.Hi,
you don't need to map all columns to the destination just map your desire columns to the appropriate columns of table. as you can see in the following snapshot that only related attributes are map and remains are un mapped.
thanks,
Zaim Raza.
-
Wednesday, June 13, 2012 3:17 AM
Ok. You could use a Derived Column (http://msdn.microsoft.com/en-us/library/ms141069) to add values to the existing 9 columns. But you'll need to add logic (via an SSIS expression) to specify the different values for each row. For example, you could use a conditional statement to specify the column value for a given row.
You could also use the OLE DB Destination or the SQL Server Destination to run an UPDATE statement with the SET argument to update values in a single column. Again, you need to specify which row or rows gets the column value (WHERE clause). For examples, see the "UPDATE (Transact-SQL)" topic in BOL. The SQL Server Destination supports bulk data load but does have some limitations. For more information about both, see SQL Server Destination (http://msdn.microsoft.com/en-us/library/ms141095) and OLE DB Destination (http://msdn.microsoft.com/en-us/library/ms141237) in BOL. Another option is adding the columns outside of the Data Flow, via the Execute SQL Task (http://msdn.microsoft.com/en-us/library/ms141003).
Carla Sabotta
- Marked As Answer by Eileen ZhaoMicrosoft Contingent Staff, Moderator Tuesday, June 19, 2012 7:43 AM
-
Wednesday, June 13, 2012 4:05 AM
the best of way to use the hardcode value in the sql statement like:
select a, b, "hardcode value" AS D from table
- Proposed As Answer by Koen VerbeeckMicrosoft Community Contributor Wednesday, June 13, 2012 7:25 AM
- Marked As Answer by Eileen ZhaoMicrosoft Contingent Staff, Moderator Tuesday, June 19, 2012 7:43 AM

