Showing posts with label step. Show all posts
Showing posts with label step. Show all posts

Tuesday, March 27, 2012

Executing exe delphi program with Agent

Hi,
I'm trying to execute a program from de agent. The program executes(i can see it in the task manager), but it block in that step and still in the task manager.
I tried with the calc.exe command with de same result.
?only DOS commands can execute the agent or there is another way to make it work?
Thanks in advance
Lomu
Hi
If the program shows a GUI then you should not run it from a scheduled job.
If you make it a command line program that will run and exit correctly then
you may be ok. Depending on what you are wanting to do there could be other
alternatives, such as writing an extended stored procedure, making it a COM
object.
John
"Lomu" <Lomu@.discussions.microsoft.com> wrote in message
news:BCDDC329-81E3-457E-90E4-3C38A830AF92@.microsoft.com...
> Hi,
> I'm trying to execute a program from de agent. The program executes(i can
see it in the task manager), but it block in that step and still in the task
manager.
> I tried with the calc.exe command with de same result.
> only DOS commands can execute the agent or there is another way to make
it work?
> Thanks in advance
> Lomu

Executing exe delphi program with Agent

Hi,
I'm trying to execute a program from de agent. The program executes(i can see it in the task manager), but it block in that step and still in the task manager.
I tried with the calc.exe command with de same result.
¿only DOS commands can execute the agent or there is another way to make it work?
Thanks in advance
LomuHi
If the program shows a GUI then you should not run it from a scheduled job.
If you make it a command line program that will run and exit correctly then
you may be ok. Depending on what you are wanting to do there could be other
alternatives, such as writing an extended stored procedure, making it a COM
object.
John
"Lomu" <Lomu@.discussions.microsoft.com> wrote in message
news:BCDDC329-81E3-457E-90E4-3C38A830AF92@.microsoft.com...
> Hi,
> I'm trying to execute a program from de agent. The program executes(i can
see it in the task manager), but it block in that step and still in the task
manager.
> I tried with the calc.exe command with de same result.
> ¿only DOS commands can execute the agent or there is another way to make
it work?
> Thanks in advance
> Lomu

Executing exe delphi program with Agent

Hi,
I'm trying to execute a program from de agent. The program executes(i can se
e it in the task manager), but it block in that step and still in the task m
anager.
I tried with the calc.exe command with de same result.
?only DOS commands can execute the agent or there is another way to make it
work?
Thanks in advance
LomuHi
If the program shows a GUI then you should not run it from a scheduled job.
If you make it a command line program that will run and exit correctly then
you may be ok. Depending on what you are wanting to do there could be other
alternatives, such as writing an extended stored procedure, making it a COM
object.
John
"Lomu" <Lomu@.discussions.microsoft.com> wrote in message
news:BCDDC329-81E3-457E-90E4-3C38A830AF92@.microsoft.com...
> Hi,
> I'm trying to execute a program from de agent. The program executes(i can
see it in the task manager), but it block in that step and still in the task
manager.
> I tried with the calc.exe command with de same result.
> only DOS commands can execute the agent or there is another way to make
it work?
> Thanks in advance
> Lomu

Monday, March 26, 2012

Executing an update command after subscription

I need to execute an update stored procedure once the subscription report
has run.
The only way I can find to do this is to add an extra TSQL step into the SQL
Agent job through SQL Management Studio. But whenever the subscription is
modified via report manager, the newly added TSQL step is deleted.
Is there a way to get around this?
Cheers
GrantHello Grant,
My suggestion is create a new SQL Job and in this job, you could first
execute the job for the subscription and then you could add your extra
taskes. The schedule of this new job could be configured as you wish.
Once you create a subsciption in the report manager, the sql server agent
will create a job which have a GUID.
You could run the following TSQL statement to run the subscription job:
exec msdb..sp_start_job @.job_name='<GUID of the subscription job>'
Hope my suggestion will be helpful!
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Monday, March 19, 2012

ExecuteNonQuery: Connection property has not been initialized

I am trying to create a web form that will be used to create new users. The
first step that I am taking is creating a web form that can check the
username against a database to see if it already exists. I would it to do
this on the fly, if possible. When I execute my current code, I get the
following error:

ExecuteNonQuery: Connection property has not been initialized

Below is the code from the page itself:
--
<!-- #INCLUDE FILE="../include/context.inc" -->
<!-- #INCLUDE FILE="../include/db_access.inc" --
<script language="VB" runat="server"
Sub CheckButton_Click(Sender as Object, e as EventArgs)

Dim result As Int32
Dim cmd As OdbcCommand

cmd = new OdbcCommand( "(? = CALL CheckUserExists(?))", db_conn )
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add( "result", OdbcType.Int ).Direction =
ParameterDirection.ReturnValue

cmd.Parameters.Add( "@.userName", OdbcType.VarChar, 100 ).Value =
Request.Form("userName")

cmd.ExecuteNonQuery()
result = cmd.Parameters("result").Value

If result <> 1 Then
CheckResults.Text="<font color=""#ff0000"">Username already
exists!</font>"
Else
CheckResults.Text="<font color=""#009900"">Username is
available.</font>"
End If

end Sub

</script
<html><body>
<form runat="server">
<asp:TextBox id=userName runat="server" />
<asp:Button id=CheckButton runat="server" Text="Check Username"
onClick="CheckButton_Click" /
<p>
<asp:Label id=CheckResults runat=server />
</form>
</body></html>
--

Can anyone see why I might get this error? Here are some more details of
the error:

Line 15: cmd.Parameters.Add( "@.userName", OdbcType.VarChar, 100 ).Value =
Request.Form("userName")
Line 16:
*Line 17: cmd.ExecuteNonQuery()
Line 18: result = cmd.Parameters("result").Value

Thank You,
Jason WilliardHi Jason,

To me it seems that you are still using asp type techniques of data access. You will have to initate your dbconnection object before you can actually use any database related functions.

With your code you are missing ofdb_conn variable. Which I am presuming that you have in include file, but this will not work with asp.net.

HTH|||It's looks like your maye be geeting error because of following reason.

1.Your connection string is not correct or not open as we can't see when and where it was intialize/open .
2.check your store procdure and see if you are passing correct parameter,correct typen etc.
3.In your code it looks likes may be you have open your connection in db_access.inc but i don't think it's good approach .you should open the connection in same sub and close as soon as you you finished.Or if you want to write neat and clean code and also don't want to wire same code agaian then create data layer class where you can perform all the database realted operation.

Arvind Malik|||I made some changes to the page so that the db connection is all done from within the Sub. Below are the code changes that I made:

--
Sub CheckButton_Click(Sender as Object, e as EventArgs)

Dim db_conn_str As String
Dim db_conn As OdbcConnection
Dim resultAs Int32
Dim cmdAs OdbcCommand
Dim context_dsn_nameAs String = "adwarefilter"

db_conn_str = "dsn=" & context_dsn_name & ";"
db_conn = New OdbcConnection( db_conn_str )
db_conn.Open()

cmd = new OdbcCommand( "(? = CALL CheckUserExists(?))", db_conn )
cmd.CommandType = CommandType.StoredProcedure
--

Now I am getting a new error message:

--
Exception Details: System.Data.Odbc.OdbcException: ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '='.

Source Error:

Line 28: cmd.Parameters.Add( "@.username", OdbcType.VarChar, 100 ).Value = Request.Form("userName")
Line 29:
Line 30: cmd.ExecuteNonQuery()
--

Any suggestions?|||What is this query: "(? = CALL CheckUserExists(?))", ? Where is the SQL Query?

Brian|||This is a call to a Stored Procedure. The SQL query is within the Stored Proc.|||I am pretty sure that your stored procedure call should look like this:


cmd = new OdbcCommand( "{CALL CheckUserExists(?)}", db_conn )

Note that I made these changes:
-- removed the question mark (?) and the equal sign (=)
-- changed a set of parentheses to a set of curly braces

But, I have a question -- why oh why are you using the System.Data.Odbc class instead of System.Data.SqlData? Are you using SQL Server 7?

Terri|||Actually, I hadn't noticed you are using a ReturnValue, sorry!! The question mark and equal sign can remain. The problem is likely just the use of parentheses instead of curly braces.


cmd = new OdbcCommand( "{? =CALL CheckUserExists(?)}", db_conn )

Terri

Friday, March 9, 2012

Execute SQL Task speed

I've created a SSIS package, in a sql 2005 instance, that uses an Execute SQL Task" to call a stored proc as its last step. When run from BIDS, the last step takes about 2 to 3 minutes, consistently. When I run the exact same query from Management Studio (either via exec <spname> or by copying the sp's t-sql code into a query window) it consistently takes about 1 minute. I've run sevral test and these number are quite reproducible.

Any ideas to account for the "slowness" of the Execute SQL Task?

TIA,

Barkingdog

Hi, are you running your package in debug mode?

Try run the package without Visual Studio.

John Bocachica - Colombia

www.iquos-bi.com

|||

The dropdown box at the top of BIDs says "Development"

Here is what I have found. My package runs three control tasks. When I run all three, the Exec SQL tasks takes about 2 minutes to run but when I execute ONLY the Exec SQL task that task runs in about 1 minute!

I saved the package (in BIDS) to a .dtsx file and ran it. The whole process took about 2.5 miniutes which tells me that the Exec SQL task still took about 2 minutes.

barkingdog

|||

What are the other tasks doing? Do they use the same database connection? Are there transactions involved?

|||

The first task truncates a table called Contact. The second task imports a CSV file into a table (uses a SQL Server Destination. Does a straight copy of the data; no transformations. The file imported is on the sql 2005 server and database I'm importing into). The third task (Exec SQL Task) applies various UPDATE statements to the table populated in step 2. Steps 2 and 3 use the same sql connection.

II don't know how to tell if all the tasks belong to the same transaction. I set up three control flows in the same pane but they are not contained in any container object, if that helps at all.)

TIA,

Barkingdog

Execute SQL Task question

I need to get the curent date from within a Execute SQL Task step,

I tried this

Declare @.Date as datetime
set @.Date = SELECT GETDATE()

..and this

Declare @.Date as datetime

set @.Date = Date

...without any luck.

I need the date as mm/dd/yyyy, anyone know how?

Thanks,
JavawabaSELECT CONVERT(varchar, GETDATE(), 101)

Greg.|||

Hello,

You can write a query like : "select convert(varchar,getdate(),101) as r_currentdt" and assign this result to some variable in the result mapping. Note:R_currentdt is a resultset name which you have to assign to some variable of the type string and can use any where within the scope.

Regards,

Raju

Wednesday, March 7, 2012

Execute SQL Insert Statement from Script Task using package OLEDB Connection

Is there a way to directly do this in one step(Execute SQL Insert Statement from Script Task using package OLEDB Connection)?

Right now I'm using a script task to build a sql insert statement using package variables (to fill values) populated by certain logic in the package.

Then assigning this command string to a package variable.

Then using a sql execute task to execute this variable.

A link to an article or code would be greatly appreciated.

You can use the classes in the System.Data.OleDB namespace and the ConnectionManager.AquireConnection method to do this. It is easiest to do this if you have an ADO.NET OLEDB connection, as that returns a managed object that you can use in your script task.

See jaegd's post in this thread for a sample. It shows use of the SQL Client, and it's a script transform rather than a task, but hopefully it's enough to get you started. If not, post back and we'll help you resolve any difficulties.

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1895867&SiteID=1

Sunday, February 19, 2012

Execute package results different to step by step execution - uses raw file

I have a package that has multiple data flow tasks. At the end of a task, key data is written into a raw file (file name stored in a variable) that is used as a data source for the next task. Each task requires a success from the preceding task.

Here's the rub:

If I execute the entire package, the results of the package (number of records of certain tasks) differs significantly from when I execute each step in the package in turn (many more records e.g. 5 vs 350).

I get the feeling that the Raw file is read into memory before it is flushed by the previous task, or that the next task begins preparation tasks too early.

Any help is greatly appreciated.

I am running on Server 2003 64 (although the same thing happens when deployed on a Server 2003 32 machine)

Thanks

B.

Hi Brian,

Interesting.

A workaround question/suggestion: Would staging the data between tasks in a database staging table work for you?

Just curious,
Andy

|||

Hi Andy,

I was hoping someone has encountered this and has a quick fix - that said....

Short answer - yes - would probably work, but I would prefer not to (I don't really like using temporary tables if I can avoid them).

The data that is being stored in the files are new guids and their relationship to old composite ids, generated during the processing of the records. I guess that storing that information in a staging database is a possibility, but I would hate to have to re-work that entire block of code.

Ideally, if it can't be stored in raw files, then connection specific temporary tables would have been my next option - but those are not really available either.

Thanks,

B.

Friday, February 17, 2012

EXECUTE master.dbo.xp_delete_file

I need to delete a file in a job as a step on a different server.

is there something simillar to this command in sql 2000?

EXECUTE master.dbo.xp_delete_file 0,N'D:\DevBack',N'bak',N'10/16/2006 15:16:22'

and what will the command look like if I need to delete only files older than 3 days?

please help

the command goes across the network

like this

EXECUTE master.dbo.xp_delete_file 0,N'\\100\00\00\02\DevBack',N'bak',N'10/16/2006 15:16:22'

|||--builds the date stamp to reflect the stamp added to the files

DECLARE @.dt datetime
DECLARE @.month varchar(2)
DECLARE @.day varchar(2)
SELECT @.dt=getdate()-1 -- 1 is the files with 1 day old
DECLARE @.builtdate varchar(8)

--this ensures a two digit value in month and day

if(len(MONTH(@.dt)) = 1 )
SET @.month = convert(varchar(2), '0' + convert(varchar(1), MONTH(@.dt)))
else
SET @.month = MONTH(@.dt)

if(len(DAY(@.dt)) = 1 )
SET @.day = convert(varchar(2), '0' + convert(varchar(1), DAY(@.dt)))
else
SET @.day = DAY(@.dt)

--this puts it all together and builds the file name match

SET @.builtdate = convert(varchar(8), convert(varchar(4),YEAR(@.dt)) + @.month + @.day)

declare @.filename varchar(100)

-- this removes all .BAK that contain the datestamp in filename

set @.filename = 'del D:\somefilepath\*'+@.builtdate+'*.BAK'

exec xp_cmdshell @.filename

-- this removes all .TRN that contain the datestamp in filename

set @.filename = 'del D:\somefilepath\*'+@.builtdate+'*.TRN'

exec xp_cmdshell @.filename