Page 1 of 1

Delete statement in Execute command stage

Posted: Thu Aug 01, 2013 1:29 pm
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

Re: Delete statement in Execute command stage

Posted: Thu Aug 01, 2013 5:23 pm
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.

Posted: Thu Aug 01, 2013 10:12 pm
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?

Posted: Thu Aug 01, 2013 10:23 pm
by ray.wurlod
1. Set your PATH environment variable correctly, or
2. Specify the full pathname of the sqlcmd command.

Posted: Thu Aug 01, 2013 10:26 pm
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!

Posted: Fri Aug 02, 2013 9:00 am
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 ?

Posted: Fri Aug 02, 2013 9:13 am
by chulett
suja.somu wrote:Where can I find the full pathname of the sqlcmd
A search from Windows Explorer should turn it up.

Posted: Fri Aug 02, 2013 2:56 pm
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!