Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


column updation


column updation

Author
Message
hassu-807119
hassu-807119
SSC Rookie
SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)

Group: General Forum Members
Points: 28 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
Mukti
Mukti
SSC Veteran
SSC Veteran (274 reputation)SSC Veteran (274 reputation)SSC Veteran (274 reputation)SSC Veteran (274 reputation)SSC Veteran (274 reputation)SSC Veteran (274 reputation)SSC Veteran (274 reputation)SSC Veteran (274 reputation)

Group: General Forum Members
Points: 274 Visits: 747
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
born2bongo
born2bongo
SSC-Enthusiastic
SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)

Group: General Forum Members
Points: 195 Visits: 351
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
hassu-807119
hassu-807119
SSC Rookie
SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)

Group: General Forum Members
Points: 28 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
born2bongo
born2bongo
SSC-Enthusiastic
SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)

Group: General Forum Members
Points: 195 Visits: 351
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.
hassu-807119
hassu-807119
SSC Rookie
SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)

Group: General Forum Members
Points: 28 Visits: 97
im asking this for some other purpose actually
Mukti
Mukti
SSC Veteran
SSC Veteran (274 reputation)SSC Veteran (274 reputation)SSC Veteran (274 reputation)SSC Veteran (274 reputation)SSC Veteran (274 reputation)SSC Veteran (274 reputation)SSC Veteran (274 reputation)SSC Veteran (274 reputation)

Group: General Forum Members
Points: 274 Visits: 747
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
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