July 18, 2008 at 1:33 pm
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
July 23, 2008 at 5:12 pm
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
July 24, 2008 at 5:59 am
hasysf (7/18/2008)
hello everyonehere 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
July 24, 2008 at 8:19 am
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
July 24, 2008 at 8:30 am
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.
July 24, 2008 at 8:40 am
im asking this for some other purpose actually
July 24, 2008 at 10:21 am
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
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply