Wednesday, March 7, 2012

Copying columns in one table in a DB to another Table in another DB

I am trying to copy two columns (OC_ID_ & OC_NAME) in one table (ORG_CHARGE)
in a SQL SRV 05 DB (VFM) into two columns (DEPT_NUM and DEPT) in another
table (DEPT) in another SQL SRV 05 DB (TRACK IT). I have to accomplish the
following with the data:
* Update if the record exists
* Add a new record in TrackIT if it does not exist
* Delete from TrackIT when it is Deleted in VFM
I have tried using the DTS export tool but end up with an error that says...
INSERT fails because it cannot insert NULL values into the column DEPT_ID.
I realize that this that i have to add an integer to increase the index of
the DEPT_ID if there are new records going into it and I have put the
necessary code to do so but I still get the error.
Any thoughts?
BFuenz
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200702/1You can write stored procedure something like that
CREATE PROC dbo.mysp
AS
IF EXISTS (SELECT * FROM Table WHERE.....)
BEGIN
UPDATE Table SET ....
DELETE FROM Table....
END
ELSE
BEGIN
INSERT INTO Table......
END
"bfuenz via droptable.com" <u31754@.uwe> wrote in message
news:6e7fe74532642@.uwe...
>I am trying to copy two columns (OC_ID_ & OC_NAME) in one table
>(ORG_CHARGE)
> in a SQL SRV 05 DB (VFM) into two columns (DEPT_NUM and DEPT) in another
> table (DEPT) in another SQL SRV 05 DB (TRACK IT). I have to accomplish
> the
> following with the data:
> * Update if the record exists
> * Add a new record in TrackIT if it does not exist
> * Delete from TrackIT when it is Deleted in VFM
> I have tried using the DTS export tool but end up with an error that
> says...
> INSERT fails because it cannot insert NULL values into the column DEPT_ID.
> I realize that this that i have to add an integer to increase the index of
> the DEPT_ID if there are new records going into it and I have put the
> necessary code to do so but I still get the error.
> Any thoughts?
> BFuenz
> --
> Message posted via droptable.com
> http://www.droptable.com/Uwe/Forum...server/200702/1
>

No comments:

Post a Comment