Delete statement in Execute command stage

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
suja.somu
Participant
Posts: 79
Joined: Thu Feb 07, 2013 10:51 pm

Delete statement in Execute command stage

Post by suja.somu »

I have a requirement to delete a table in Sql server after a job finishes successfully.

I can do this with execute command stage.

Can anyone help with the syntax of the connection details. i tried the below it does not work

delete from Datamart.dbo.sample ;| userid/pwd@servername
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Re: Delete statement in Execute command stage

Post by SURA »

This is not the way to execute the command.

Code: Select all

sqlcmd -S Database-U Userid -P Password .....and so on
Type sqlcmd/? in your command prompt for options

You are trying to execute it from execute command, but is there is any specific reason to execute it from sequence?

To delete a table there are good number of ways to do that! For example in the SQL Server stage itself there is are options to execute the DELETE statement in the Properties --> Option.
Thanks
Ram
----------------------------------
Revealing your ignorance is fine, because you get a chance to learn.
suja.somu
Participant
Posts: 79
Joined: Thu Feb 07, 2013 10:51 pm

Post by suja.somu »

Thanks for your reply.

I tried to execute the command

sqlcmd -S servername -U userid -P pwd delete from DatabaseA.TablenameA;

it throws a error:
'sqlcmd' is not recognized as an internal or external command,operable program or batch file.

My reqt is : Query a table A in Database A and load to table B in Database B.

After successful load to table B in Database B. the table A has to be truncated.

What are the ways to acheive this?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

1. Set your PATH environment variable correctly, or
2. Specify the full pathname of the sqlcmd command.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Post by SURA »

suja.somu wrote:the table A has to be truncated.
What are the ways to acheive this?
Yes, do as Ray said.

Just a clarification.

Initially you asked a question to delete a table and not to truncate :) Please make sure what you are going to do!
Thanks
Ram
----------------------------------
Revealing your ignorance is fine, because you get a chance to learn.
suja.somu
Participant
Posts: 79
Joined: Thu Feb 07, 2013 10:51 pm

Post by suja.somu »

As per Rays suggestion to get the command to work, Where can I find the full pathname of the sqlcmd or how to set the path environment variable ?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

suja.somu wrote:Where can I find the full pathname of the sqlcmd
A search from Windows Explorer should turn it up.
-craig

"You can never have too many knives" -- Logan Nine Fingers
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Post by SURA »

suja.somu wrote:how to set the path environment variable ?
Google the same word "how to...." you will get the answer .

As suggested you search in your machine for sqlcmd or right click the SQL Server in the all programes will let you know where it is installed. Then go to that Drive and find.

Once you found, then give the full path ( if env is not set) of sqlcmd /?. This will tell you what all are the option available!
Thanks
Ram
----------------------------------
Revealing your ignorance is fine, because you get a chance to learn.
Post Reply