Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

column updation Expand / Collapse
Author
Message
Posted Friday, July 18, 2008 1:33 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, January 14, 2009 7:16 AM
Points: 26, Visits: 97
hello everyone
here is the scenario. I have a table in the oracle database and i am transfering its data to the sql server 2005. My destination table has all the null columns except the primary key. Now i am using column mapping to import the data from oracle to sql in the columns other than primary key but it gives me error that u can not insert null in the primary key column when in fact its already has data. So please guide me how to insert or what ever i should do to get the data in the desired columns
thanks
Post #537036
Posted Wednesday, July 23, 2008 5:12 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, February 24, 2014 11:26 AM
Points: 226, Visits: 715
If you are using Data flow task and just using Oracle Source and SQL destination, the insert will fail becoz the task is trying to insert new records. As you said you already have data in your SQL table you just need to update the other columns with values from Oracle. There are many ways to accomplish this: You can use whichever you like based on size of your table (for performance)
1. Add slowly chaning dimention task to your data flow and update your SQL table based on your primary key.
2. you can loop through the recods from oracle using foreach loop and update the sql table records
3. you can bring all data from Oracle into staging and then write simple sql update statement to update all the columns in your sql table.

HTH
~Mukti
Post #539780
Posted Thursday, July 24, 2008 5:59 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, August 21, 2013 3:12 AM
Points: 157, Visits: 349
hasysf (7/18/2008)
hello everyone
here is the scenario. I have a table in the oracle database and i am transfering its data to the sql server 2005. My destination table has all the null columns except the primary key. Now i am using column mapping to import the data from oracle to sql in the columns other than primary key but it gives me error that u can not insert null in the primary key column when in fact its already has data. So please guide me how to insert or what ever i should do to get the data in the desired columns
thanks


I read the previous post and I don't think you got the answer you wanted - apologies to you both if I'm wrong.

I think you have an empty sql server table and want to populate it with all the columns from the Oracle table. You have mapped everything except the primary key.

I am guessing you want the primary key to generate its own unique value (like an Access autonumber data type). If this is the case, you need to change the design of the table in SQL Server.

If you modify the table design and look at the column properties for the primary key column you will see values under the heading Table Designer.

There is one called Identity Specification and you should set this to 'Yes'. (If you are letting your primary key populate itself I am assuming it is an int or bigint, or similar). Under this property are the sub properties Identity Increment and Identity Seed. They default to 1 and the latter means start at 1 while the former means increment by 1. You can change these at will.

If I have read you right and you do this, your package should run fine
Post #540032
Posted Thursday, July 24, 2008 8:19 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, January 14, 2009 7:16 AM
Points: 26, Visits: 97
i just wanted to ask one thing for you
how to use the variables in the execute sql task to retrieve the oracle table records and then do a for each loop on the record set to execute the required recordset
Post #540203
Posted Thursday, July 24, 2008 8:30 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, August 21, 2013 3:12 AM
Points: 157, Visits: 349
Myself and the previous poster thought you were using a data flow task. That would be easiest.

Add a data flow task to the contol page; set up a connection to the oracle database and another for the SQL Server database, add a data source in the data flow. You will probably need a data conversion transformation, and then a destination control to output to the SQL Server table. You will be able to map the input columns to the output table with no need to loop through record sets.

Post #540213
Posted Thursday, July 24, 2008 8:40 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, January 14, 2009 7:16 AM
Points: 26, Visits: 97
im asking this for some other purpose actually
Post #540223
Posted Thursday, July 24, 2008 10:21 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, February 24, 2014 11:26 AM
Points: 226, Visits: 715
For using variables in SQL Task you need to use the Parameter mapping and map the variables. Depending on your connection type the parameter marker and parameter name would differ. Please go through http://technet.microsoft.com/en-us/library/ms141003.aspx for details.

And for using the resultset returned from your query, you need to use Foreach loop with ADO enumerator. The following link is a very good example for the same:

http://www.codeproject.com/KB/database/foreachadossis.aspx

HTH
~Mukti

Post #540345
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse