473,657 Members | 2,484 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Executing a job using TSQL or Stored procedure on SQL 2005 Express

I need to execute a job on a SQL Express 2005 instance (no SQLAgent).
The job will be executed manually by a user, so it doesn't need to be
scheduled to run automatically. I thought I could execute the job
through a stored procedure, but it appears that SQL Agent is necessary
even for that.

The job was given to me by a software vendor to add EDI capabilities
to an accounting package, but the assumption was made that a full
version of SQL was available.

Is there another way to execute a job on an Express instance? The job
has 4 steps. Two are just executing stored procedures, which I could
easily do via another stored procedure. But the other two steps are
Activescripting/VBScript ( @subsystem=N'Ac tiveScripting') and involve
creating text files and starting a ftp session to transfer them... And
that's a bit beyond me..

Thanks

Nov 21 '08 #1
2 7466
On Fri, 21 Nov 2008 00:43:10 -0500, Carlton Kirby
<ckirbyATmindsp ringdottcomwrot e:

Jobs seem tightly related to SQLAgent. So you either upgrade, or have
someone with VBScript skills take a look at those scripts.
If a VBScript was in a file, it could be executed like this:
cscript.exe c:\my.vbs
Scripts can extract data from a SQLServer, e.g. using ADO.
You may also be able to export the data some other way, e.g. BCP.

-Tom.
Microsoft Access MVP
>I need to execute a job on a SQL Express 2005 instance (no SQLAgent).
The job will be executed manually by a user, so it doesn't need to be
scheduled to run automatically. I thought I could execute the job
through a stored procedure, but it appears that SQL Agent is necessary
even for that.

The job was given to me by a software vendor to add EDI capabilities
to an accounting package, but the assumption was made that a full
version of SQL was available.

Is there another way to execute a job on an Express instance? The job
has 4 steps. Two are just executing stored procedures, which I could
easily do via another stored procedure. But the other two steps are
Activescriptin g/VBScript ( @subsystem=N'Ac tiveScripting') and involve
creating text files and starting a ftp session to transfer them... And
that's a bit beyond me..

Thanks
Nov 21 '08 #2
So I should be able to take the text from the VBScript job step and
save it to a vbs file, then run it using the cscript.exe?
Here's the text of the Job, step 2 :


EXEC @ReturnCode = msdb.dbo.sp_add _jobstep @job_id=@jobId,
@step_name=N'Ou tputInvoiceExpo rtTextFiles',
@step_id=2,
@cmdexec_succes s_code=0,
@on_success_act ion=4,
@on_success_ste p_id=3,
@on_fail_action =2,
@on_fail_step_i d=0,
@retry_attempts =0,
@retry_interval =0,
@os_run_priorit y=0, @subsystem=N'Ac tiveScripting',
@command=N'Dim oFilesys
Dim oFiletxt
Dim sFilename
Dim strPath
Dim sFullFileName
Dim strdbConnectStr ing
Dim dbConnection
Dim rsOutput
Dim sqlCommand
Dim strDatabaseName
Dim sqlCommandGroup
Dim rsGroup
Dim sKey
Dim sValue
Dim FsoObject
Dim strSourceFile
Dim OpenFile
Dim strInputLine

Const cForReading = 1
Const cForWriting = 2
Const cForAppending = 8

Call LoadParameters( )

Public Sub LoadParameters( )
Set FsoObject = CreateObject("S cripting.FileSy stemObject")

strSourceFile = "C:\Program Files\TSM105\ED IConfigSettings .txt"

If (FsoObject.File Exists(strSourc eFile)) Then
Set OpenFile = FsoObject.OpenT extFile(strSour ceFile, cForReading)

Do Until Mid(strInputLin e, 1, 15) = "[CreateInvoice]"
strInputLine = OpenFile.ReadLi ne
Loop

Do Until OpenFile.AtEndO fStream = "True"
strInputLine = OpenFile.ReadLi ne
If Mid(strInputLin e, 1, 1) = "[" Then
Exit Do
End If
If Instr(strInputL ine, "=") 1 Then
sKey = Ltrim(Rtrim(Lef t(strInputLine, instr(strInputL ine,
"=") - 1)))
sValue = Ltrim(Rtrim(mid (strInputLine, instr(strInputL ine,
"=") + 1, 255)))
End if

If sKey = "Path" then
strPath = sValue
ElseIf sKey = "dbConnectStrin g" then
strdbConnectStr ing = sValue
ElseIf sKey = "DatabaseNa me" then
strDatabaseName = sValue
End If
Loop

OpenFile.Close
Set FsoObject = nothing
Else
Err.Raise vbObjectError, "LoadParameters ", "Error: " &
strSourceFile & " does not exist."
End If
End Sub

''set the select statement to retrieve each distinct Retailer Hub Code
sqlCommandGroup = "SELECT DISTINCT RetailerHubCode , InvcNum FROM [" +
strDatabaseName + "]..tmpEDIInvoice Export WHERE RetailerHubCode IS NOT
NULL"

''create and open a connection to the sql server
Set dbConnection = CreateObject("A DODB.Connection ")
dbConnection.Op en = strdbConnectStr ing

''open the recordset to copy into the text file
Set rsGroup = CreateObject("A DODB.Recordset" )
rsGroup.Open sqlCommandGroup , dbConnection
If not (rsGroup.BOF) Then rsGroup.MoveFir st

''loop through each Retailer Hub Code
While (Not rsGroup.EOF)
''build the invoice number based file name using the Retailer
Hub Code as the file extension

sFileName = "IN" + rsGroup("InvcNu m") + "." +
rsGroup("Retail erHubCode")

''combine the path and filename
sFullFileName = strPath + sFileName

''use a file system object to create a text file
Set oFilesys = CreateObject("S cripting.FileSy stemObject")

Set oFiletxt = oFilesys.Create TextFile(sFullF ileName, True)

''set the select statement to retrieve all records for the
current Retailer Hub Code
sqlCommand = "SELECT CombinedFields FROM [" + strDatabaseName
+ "]..tmpEDIInvoice Export WHERE RetailerHubCode = ''" +
rsGroup("Retail erHubCode") + "'' AND InvcNum = ''" +
rsGroup("InvcNu m") + "''"

''open the recordset to copy into the text file
Set rsOutput = CreateObject("A DODB.Recordset" )
rsOutput.Open sqlCommand, dbConnection
If not (rsOutput.BOF) Then rsOutput.MoveFi rst

''write each record into the text file
While (Not rsOutput.EOF)
oFiletxt.Write (rsOutput("Comb inedFields") + VbCrLf)
rsOutput.MoveNe xt
Wend

rsOutput.Close
oFiletxt.Close
set rsOutput = nothing
set oFiletxt = nothing
set oFileSys = nothing

rsGroup.MoveNex t
Wend

rsGroup.Close
dbConnection.Cl ose

set dbConnection = nothing
set rsGroup = nothing',
@database_name= N'VBScript',
@flags=0

I should take the text in the @command line and move that out to a vbs
file, right?

On Fri, 21 Nov 2008 07:42:46 -0700, Tom van Stiphout
<to************ *@cox.netwrote:
>On Fri, 21 Nov 2008 00:43:10 -0500, Carlton Kirby
<ckirbyATminds pringdottcomwro te:

Jobs seem tightly related to SQLAgent. So you either upgrade, or have
someone with VBScript skills take a look at those scripts.
If a VBScript was in a file, it could be executed like this:
cscript.exe c:\my.vbs
Scripts can extract data from a SQLServer, e.g. using ADO.
You may also be able to export the data some other way, e.g. BCP.

-Tom.
Microsoft Access MVP
>>I need to execute a job on a SQL Express 2005 instance (no SQLAgent).
The job will be executed manually by a user, so it doesn't need to be
scheduled to run automatically. I thought I could execute the job
through a stored procedure, but it appears that SQL Agent is necessary
even for that.

The job was given to me by a software vendor to add EDI capabilities
to an accounting package, but the assumption was made that a full
version of SQL was available.

Is there another way to execute a job on an Express instance? The job
has 4 steps. Two are just executing stored procedures, which I could
easily do via another stored procedure. But the other two steps are
Activescripti ng/VBScript ( @subsystem=N'Ac tiveScripting') and involve
creating text files and starting a ftp session to transfer them... And
that's a bit beyond me..

Thanks
Nov 21 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
16289
by: randi_clausen | last post by:
Using SQL against a DB2 table the 'with' key word is used to dynamically create a temporary table with an SQL statement that is retained for the duration of that SQL statement. What is the equivalent to the SQL 'with' using TSQL? If there is not one, what is the TSQL solution to creating a temporary table that is associated with an SQL statement? Examples would be appreciated. Thank you!!
11
4458
by: athos | last post by:
Hi guys, Sounds a bit strange, however, if we could put some calculation in stored procedure it would be quite convenient, just... where can I find a REGEXP library for matching checking? thanks. yours, athos
2
3966
by: Not Me | last post by:
Hey, Coming back to a piece of work I did a while back, which used a stored procedure to populate a list box. The SP takes a single parameter, and I think this is the reasoning for using 'exec' in the row source (I assume you need this for parameters?) The problem is this only works when I access the form.. If I do it from someone else's computer they get a blank listbox. They have appropriate permissions for the stored procedure,...
0
1073
by: Daniel | last post by:
will a client application using ado.net get an exception if the command is executing a stored procedure that does a RAISEERROR in its tsql?
13
4853
by: Filips Benoit | last post by:
Dear All, How can I show the resultrecords of a SP. I can be done by doubleclick the SPname? But how to do it by code. I want the following interface In my form the user 1 selects a SP (combobox showing a userfrinly name) 2 adds the related parameters
7
9379
by: Filips Benoit | last post by:
Dear all, Tables: COMPANY: COM_ID, COM_NAME, ..... PROPERTY: PRP_ID, PRP_NAME, PRP_DATATYPE_ID, PRP_DEFAULT_VALUE ( nvarchar) COMPANY_PROPERTY: CPROP_COM_ID, CPROP_PRP_ID, CPROP_VALUE (nvarchar) Use: Without adding new field the user can add new properties to the companies just by adding a new property in table PROPERTY and mapping the
3
6039
by: Goog79 | last post by:
Hi everyone, first time here, so I'm sorry if this has been covered already ages ago. :( I am trying to learn T-SQL and Stored Procedures and bought the book on these topics by Djan Sunderic, Publisher McGraw Hill/Osborne. I'm already stuck on my first Stored Procedure and getting error messages that I cannot understand. I've already tried Google and Microsoft online to no avail. I do have the .NET Framework on my system and use
2
6742
by: moforiappiah | last post by:
I urgently need help on how to execute a stored procedure in SQL Express 2005. I have created a stored procedure with as follows: Create Procedure upInsertCountry @CountryName varchar(50) INSERT INTO CountryTable (CountryName) VALUES (@CountryName) When run the following code :
4
2979
by: jleeie | last post by:
Can someone help me, I'm going round in circles with this and my head is cabbaged ! I am using visual studio 2005 & VB & MS SQL 2005 I am trying to execute a stored procedure from within a program. I want to return values. I can get a 0 or 1 returned. I don't seem to be able to get any other value returned. below is my VB code and the stored procedure. I would really appreciate if someone would have a look that knows how to do this....
0
8421
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8325
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8742
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7354
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.