Truncating a SQL Server Table

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
smoffa
Premium Member
Premium Member
Posts: 40
Joined: Wed Jun 30, 2004 6:00 am
Location: Orlando, FL
Contact:

Truncating a SQL Server Table

Post by smoffa »

I am new to Parallel jobs an was wondering how to Truncate a SQL server table before I insert. I'm using the enterprise SQL Server stage. I have tried searching for this answer but could not find this topic.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Don't have any docs or DataStage in front of me at the moment... usually there is an Update Action akin to "Clear table then Insert" and in most cases that "clear" means truncate. Do you see any such thing in the stage?
-craig

"You can never have too many knives" -- Logan Nine Fingers
smoffa
Premium Member
Premium Member
Posts: 40
Joined: Wed Jun 30, 2004 6:00 am
Location: Orlando, FL
Contact:

Post by smoffa »

I can set the "Write Method" property = Write, then the stage allows me to set the "Write Mode" = Truncate. However, then the SQL property goes away so I'm not able to enter my insert statement. I must be missing something.

I don't see any before/after SQL tabs/properties either.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

When you set those properties, there's really no reason for you to be inserting any kind of sql statement - the stage should handle all that for you automagically. Why not just give it a try and see if that works or not? And then let us know, too. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
smoffa
Premium Member
Premium Member
Posts: 40
Joined: Wed Jun 30, 2004 6:00 am
Location: Orlando, FL
Contact:

Post by smoffa »

Thanks Craig. I got some other error message (Query execute failed) but the insert seemed to work. I guess I still need to get used to parallel jobs.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Can you copy/paste your new error message here? Is the truncation part working for you in addition to the inserts?
-craig

"You can never have too many knives" -- Logan Nine Fingers
smoffa
Premium Member
Premium Member
Posts: 40
Joined: Wed Jun 30, 2004 6:00 am
Location: Orlando, FL
Contact:

Post by smoffa »

Yes, the truncate and the insert seems to be working. However, I get a fatal error but the job continues and completes.

The exact error is:

HRO_LOCATIONS: Query execute failed

Where HRO_LOCATIONS is the name of my sql server target stage.
Post Reply