Thursday, March 29, 2012

Executable or Way for User to Launch an SQL Package?

I have a sitation where I need a dts package or similar to run at a user initiated time. I do not want to give the user access to the server. Any ideas on how one goes about something like this?Howdy

If its through a web or VB type app, let the web app execute a stored procedure called by the app.

Cheers,

SG.|||Hey,
from a vb app or vb script you can do this function:

Public Sub ExecuteEDIPackage(FileName As Variant)

Dim sServer As String
Dim sUsername As String
Dim sPassword As String
Dim sPackageName As String
Dim lErr As Long
Dim sSource As String
Dim sDesc As String

Set oPKG = New DTS.Package

' Set Parameter Values
sPackageName = "EDIPackage"

' Load Package
oPKG.LoadFromSQLServer DataSource, UserName, Password, _
DTSSQLStgFlag_Default, , , , sPackageName

' Set Exec on Main Thread
For Each oStep In oPKG.Steps
oStep.ExecuteInMainThread = True
Next

' Execute
oPKG.Execute

' Get Status and Error Message
For Each oStep In oPKG.Steps
If oStep.ExecutionResult = DTSStepExecResult_Failure Then
oStep.GetExecutionErrorInfo lErr, sSource, sDesc
sMessage = sMessage & "Step """ & oStep.Name & _
""" Failed" & vbCrLf & _
vbTab & "Error: " & lErr & vbCrLf & _
vbTab & "Source: " & sSource & vbCrLf & _
vbTab & "Description: " & sDesc & vbCrLf & vbCrLf
Else
sMessage = sMessage & "Step """ & oStep.Name & _
""" Succeeded" & vbCrLf & vbCrLf
End If
Next

oPKG.UnInitialize

Set oStep = Nothing
Set oPKG = Nothing

End Sub

execure store procedure from Query Analizer

Hi,
I am trying to execute a store procedure from the query analyzer, but I get
following error "Could not find stored procedure 'GetSubscriptions'", my
store procedure has 3 parameters.
I wrote the following statements to the Query Analizer:
Declare @.Par1 as int, @.Par2 as varchar , @.Par3 as varchar
set @.Par1 = 1
set @.Par2 = 'some value'
set @.Par2 = 'some value'
exec GetSubscriptions; 3
What can I do?
Tnx in advance
Isambella
Message posted via http://www.droptable.com
Hi Isambella
You try this way
set @.Par1 = 1
set @.Par2 = 'some value'
set @.Par2 = 'some value'
exec <database_name>..GetSubscriptions @.par1, @.par2, @.par3
Probably you are trying to execute the SP in a different database
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.codecomments.com/gurus/default.asp?p=4223
"Isambella via droptable.com" wrote:

> Hi,
> I am trying to execute a store procedure from the query analyzer, but I get
> following error "Could not find stored procedure 'GetSubscriptions'", my
> store procedure has 3 parameters.
> I wrote the following statements to the Query Analizer:
> Declare @.Par1 as int, @.Par2 as varchar , @.Par3 as varchar
> set @.Par1 = 1
> set @.Par2 = 'some value'
> set @.Par2 = 'some value'
> exec GetSubscriptions; 3
> What can I do?
> Tnx in advance
> Isambella
> --
> Message posted via http://www.droptable.com
>
|||On Thu, 12 May 2005 23:02:02 -0700, Chandra wrote:
> Probably you are trying to execute the SP in a different database
And if that doesn't help, check who the owner of the procedure is. You
might have to run it using something like: "DATABASE.USER.GetSubscriptions".
HTH,
Andrs Taylor
|||I did the following:
exec GetSubscriptions @.Par1 = 1, @.Par2 = 'some value', @.Par3 = 'some value'
Its ok now
Thx
Isambella
Message posted via http://www.droptable.com
|||I ran your code and recieved the same error. You need to check to see if
stored procedure exist and if so drop it and then write create procedure
process before you can execute the paramaters. Please refer to example below.
-- creating the store procedure
IF EXISTS (SELECT 1
FROM [dbo].[sysobjects] (NOLOCK)
WHERE [ID] = OBJECT_ID(N'Create_NEWSP' )
AND OBJECTPROPERTY =[ID],N'IsProcedure') =1)
BEGIN-- Drop Stored Procedure
DROP PROCEDURE Create_NEWSP
END-- Drop Stored Procedure
GO
CREATE PROCEDURE Create_NEWSP
@.p1 INT = 0,
@.p2 INT = 0
AS
SELECT @.p1, @.p2
GO
-- execute the store procedure
EXECUTE Create_NEWSP 1, 2
GO
"Isambella via droptable.com" wrote:

> Hi,
> I am trying to execute a store procedure from the query analyzer, but I get
> following error "Could not find stored procedure 'GetSubscriptions'", my
> store procedure has 3 parameters.
> I wrote the following statements to the Query Analizer:
> Declare @.Par1 as int, @.Par2 as varchar , @.Par3 as varchar
> set @.Par1 = 1
> set @.Par2 = 'some value'
> set @.Par2 = 'some value'
> exec GetSubscriptions; 3
> What can I do?
> Tnx in advance
> Isambella
> --
> Message posted via http://www.droptable.com
>

execure store procedure from Query Analizer

Hi,
I am trying to execute a store procedure from the query analyzer, but I get
following error "Could not find stored procedure 'GetSubscriptions'", my
store procedure has 3 parameters.
I wrote the following statements to the Query Analizer:
Declare @.Par1 as int, @.Par2 as varchar , @.Par3 as varchar
set @.Par1 = 1
set @.Par2 = 'some value'
set @.Par2 = 'some value'
exec GetSubscriptions; 3
What can I do?
Tnx in advance
Isambella
--
Message posted via http://www.sqlmonster.comHi Isambella
You try this way
set @.Par1 = 1
set @.Par2 = 'some value'
set @.Par2 = 'some value'
exec <database_name>..GetSubscriptions @.par1, @.par2, @.par3
Probably you are trying to execute the SP in a different database
--
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.developersdex.com/gurus/default.asp?p=4223
---
"Isambella via SQLMonster.com" wrote:
> Hi,
> I am trying to execute a store procedure from the query analyzer, but I get
> following error "Could not find stored procedure 'GetSubscriptions'", my
> store procedure has 3 parameters.
> I wrote the following statements to the Query Analizer:
> Declare @.Par1 as int, @.Par2 as varchar , @.Par3 as varchar
> set @.Par1 = 1
> set @.Par2 = 'some value'
> set @.Par2 = 'some value'
> exec GetSubscriptions; 3
> What can I do?
> Tnx in advance
> Isambella
> --
> Message posted via http://www.sqlmonster.com
>|||On Thu, 12 May 2005 23:02:02 -0700, Chandra wrote:
> Probably you are trying to execute the SP in a different database
And if that doesn't help, check who the owner of the procedure is. You
might have to run it using something like: "DATABASE.USER.GetSubscriptions".
HTH,
Andrés Taylor|||I did the following:
exec GetSubscriptions @.Par1 = 1, @.Par2 = 'some value', @.Par3 = 'some value'
Its ok now
Thx
Isambella
--
Message posted via http://www.sqlmonster.com|||I ran your code and recieved the same error. You need to check to see if
stored procedure exist and if so drop it and then write create procedure
process before you can execute the paramaters. Please refer to example below.
-- creating the store procedure
IF EXISTS (SELECT 1
FROM [dbo].[sysobjects] (NOLOCK)
WHERE [ID] = OBJECT_ID(N'Create_NEWSP' )
AND OBJECTPROPERTY =[ID],N'IsProcedure') =1)
BEGIN-- Drop Stored Procedure
DROP PROCEDURE Create_NEWSP
END-- Drop Stored Procedure
GO
CREATE PROCEDURE Create_NEWSP
@.p1 INT = 0,
@.p2 INT = 0
AS
SELECT @.p1, @.p2
GO
-- execute the store procedure
EXECUTE Create_NEWSP 1, 2
GO
"Isambella via SQLMonster.com" wrote:
> Hi,
> I am trying to execute a store procedure from the query analyzer, but I get
> following error "Could not find stored procedure 'GetSubscriptions'", my
> store procedure has 3 parameters.
> I wrote the following statements to the Query Analizer:
> Declare @.Par1 as int, @.Par2 as varchar , @.Par3 as varchar
> set @.Par1 = 1
> set @.Par2 = 'some value'
> set @.Par2 = 'some value'
> exec GetSubscriptions; 3
> What can I do?
> Tnx in advance
> Isambella
> --
> Message posted via http://www.sqlmonster.com
>sql

execure store procedure from Query Analizer

Hi,
I am trying to execute a store procedure from the query analyzer, but I get
following error "Could not find stored procedure 'GetSubscriptions'", my
store procedure has 3 parameters.
I wrote the following statements to the Query Analizer:
Declare @.Par1 as int, @.Par2 as varchar , @.Par3 as varchar
set @.Par1 = 1
set @.Par2 = 'some value'
set @.Par2 = 'some value'
exec GetSubscriptions; 3
What can I do?
Tnx in advance
Isambella
Message posted via http://www.droptable.comHi Isambella
You try this way
set @.Par1 = 1
set @.Par2 = 'some value'
set @.Par2 = 'some value'
exec <database_name>..GetSubscriptions @.par1, @.par2, @.par3
Probably you are trying to execute the SP in a different database
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.codecomments.com/gurus/default.asp?p=4223
---
"Isambella via droptable.com" wrote:

> Hi,
> I am trying to execute a store procedure from the query analyzer, but I ge
t
> following error "Could not find stored procedure 'GetSubscriptions'", my
> store procedure has 3 parameters.
> I wrote the following statements to the Query Analizer:
> Declare @.Par1 as int, @.Par2 as varchar , @.Par3 as varchar
> set @.Par1 = 1
> set @.Par2 = 'some value'
> set @.Par2 = 'some value'
> exec GetSubscriptions; 3
> What can I do?
> Tnx in advance
> Isambella
> --
> Message posted via http://www.droptable.com
>|||On Thu, 12 May 2005 23:02:02 -0700, Chandra wrote:
> Probably you are trying to execute the SP in a different database
And if that doesn't help, check who the owner of the procedure is. You
might have to run it using something like: "DATABASE.USER.GetSubscriptions".
HTH,
Andrs Taylor|||I did the following:
exec GetSubscriptions @.Par1 = 1, @.Par2 = 'some value', @.Par3 = 'some value'
Its ok now
Thx
Isambella
Message posted via http://www.droptable.com|||I ran your code and recieved the same error. You need to check to see if
stored procedure exist and if so drop it and then write create procedure
process before you can execute the paramaters. Please refer to example belo
w.
-- creating the store procedure
IF EXISTS (SELECT 1
FROM [dbo].[sysobjects] (NOLOCK)
WHERE [ID] = OBJECT_ID(N'Create_NEWSP' )
AND OBJECTPROPERTY =[ID],N'IsProcedure') =1)
BEGIN-- Drop Stored Procedure
DROP PROCEDURE Create_NEWSP
END-- Drop Stored Procedure
GO
CREATE PROCEDURE Create_NEWSP
@.p1 INT = 0,
@.p2 INT = 0
AS
SELECT @.p1, @.p2
GO
-- execute the store procedure
EXECUTE Create_NEWSP 1, 2
GO
"Isambella via droptable.com" wrote:

> Hi,
> I am trying to execute a store procedure from the query analyzer, but I ge
t
> following error "Could not find stored procedure 'GetSubscriptions'", my
> store procedure has 3 parameters.
> I wrote the following statements to the Query Analizer:
> Declare @.Par1 as int, @.Par2 as varchar , @.Par3 as varchar
> set @.Par1 = 1
> set @.Par2 = 'some value'
> set @.Par2 = 'some value'
> exec GetSubscriptions; 3
> What can I do?
> Tnx in advance
> Isambella
> --
> Message posted via http://www.droptable.com
>

exectuing a .bat from cmdexec

All,
sql 2000 sp3
I have a .bat file at d:\wip\queries.bat, the step succeeds, but there is no
data in the files that I am creating. Below is the contents of the .bat. I
have 'd:\queries.bat' in the cmdexec step. I have verified the odbc
connection, any other ideas would be a great help.
db2cmd /c /w /i db2 +o -tf ds1_query.sql -r d:\wip\ds1_query.txt
db2cmd /c /w /i db2 +o -tf ds2_wrs_ind_employee_db2_query.sql -r
d:\wip\ds2_wrs_ind_employee_db2.txt
db2cmd /c /w /i db2 +o -tf ds3_wrs_clr_employee_db2_query.sql -r
d:\wip\ds3_wrs_clr_employee_db2.txt
db2cmd /c /w /i db2 +o -tf ds4_wrs_client_db2_query.sql -r
d:\wip\ds4_wrs_client_db2.txt
db2cmd /c /w /i db2 +o -tf ds5_wrs_diary_db2_query.sql -r
d:\wip\ds5_wrs_diary_db2.txt
db2cmd /c /w /i db2 +o -tf ds6_wrs_dry_history_db2_query.sql -r
d:\wip\ds6_wrs_dry_history_db2.txt
db2cmd /c /w /i db2 +o -tf ds7_wrs_folder_control_db2_query.sql -r
d:\wip\ds7_wrs_folder_control_db2.txt
--
Thanks,
SnyperSorry, the step does fail. I see it in the appliction log as a failure. I do
not know how to get the .bat to execute properly. Any ideas?
--
Thanks,
Snyper
"snyper" wrote:
> All,
> sql 2000 sp3
> I have a .bat file at d:\wip\queries.bat, the step succeeds, but there is no
> data in the files that I am creating. Below is the contents of the .bat. I
> have 'd:\queries.bat' in the cmdexec step. I have verified the odbc
> connection, any other ideas would be a great help.
> db2cmd /c /w /i db2 +o -tf ds1_query.sql -r d:\wip\ds1_query.txt
> db2cmd /c /w /i db2 +o -tf ds2_wrs_ind_employee_db2_query.sql -r
> d:\wip\ds2_wrs_ind_employee_db2.txt
> db2cmd /c /w /i db2 +o -tf ds3_wrs_clr_employee_db2_query.sql -r
> d:\wip\ds3_wrs_clr_employee_db2.txt
> db2cmd /c /w /i db2 +o -tf ds4_wrs_client_db2_query.sql -r
> d:\wip\ds4_wrs_client_db2.txt
> db2cmd /c /w /i db2 +o -tf ds5_wrs_diary_db2_query.sql -r
> d:\wip\ds5_wrs_diary_db2.txt
> db2cmd /c /w /i db2 +o -tf ds6_wrs_dry_history_db2_query.sql -r
> d:\wip\ds6_wrs_dry_history_db2.txt
> db2cmd /c /w /i db2 +o -tf ds7_wrs_folder_control_db2_query.sql -r
> d:\wip\ds7_wrs_folder_control_db2.txt
> --
> Thanks,
> Snyper|||Snyper
Although i know nothing of the detail of what you are trying to do here ...
If running the indiviual commands are being created but not populted then
perhaps it might be worth looking at it being a permissions error in creating
the information or permisiions on population the file.
when you run one of these commands what permissions context is it running
under
under, your id, under the os id or under the applicaion you are running the
commands from.
Are the drive letters in the contect of the user and location you are
running them from ie if runnind this on a remote serverits D: will not be the
same as you d:
perhap you need to qualify the files such \\<severname>\<sharename>
Can you break these commands down
a simpler command to say display a directory listing work via this method ie
the cmdexec works but not he commnd you are running...
"snyper" wrote:
> Sorry, the step does fail. I see it in the appliction log as a failure. I do
> not know how to get the .bat to execute properly. Any ideas?
> --
> Thanks,
> Snyper
>
> "snyper" wrote:
> > All,
> >
> > sql 2000 sp3
> >
> > I have a .bat file at d:\wip\queries.bat, the step succeeds, but there is no
> > data in the files that I am creating. Below is the contents of the .bat. I
> > have 'd:\queries.bat' in the cmdexec step. I have verified the odbc
> > connection, any other ideas would be a great help.
> >
> > db2cmd /c /w /i db2 +o -tf ds1_query.sql -r d:\wip\ds1_query.txt
> > db2cmd /c /w /i db2 +o -tf ds2_wrs_ind_employee_db2_query.sql -r
> > d:\wip\ds2_wrs_ind_employee_db2.txt
> > db2cmd /c /w /i db2 +o -tf ds3_wrs_clr_employee_db2_query.sql -r
> > d:\wip\ds3_wrs_clr_employee_db2.txt
> > db2cmd /c /w /i db2 +o -tf ds4_wrs_client_db2_query.sql -r
> > d:\wip\ds4_wrs_client_db2.txt
> > db2cmd /c /w /i db2 +o -tf ds5_wrs_diary_db2_query.sql -r
> > d:\wip\ds5_wrs_diary_db2.txt
> > db2cmd /c /w /i db2 +o -tf ds6_wrs_dry_history_db2_query.sql -r
> > d:\wip\ds6_wrs_dry_history_db2.txt
> > db2cmd /c /w /i db2 +o -tf ds7_wrs_folder_control_db2_query.sql -r
> > d:\wip\ds7_wrs_folder_control_db2.txt
> > --
> >
> > Thanks,
> >
> > Snyper

exectuing a .bat from cmdexec

All,
sql 2000 sp3
I have a .bat file at d:\wip\queries.bat, the step succeeds, but there is no
data in the files that I am creating. Below is the contents of the .bat. I
have 'd:\queries.bat' in the cmdexec step. I have verified the odbc
connection, any other ideas would be a great help.
db2cmd /c /w /i DB2 +o -tf ds1_query.sql -r d:\wip\ds1_query.txt
db2cmd /c /w /i DB2 +o -tf ds2_wrs_ind_employee_db2_query.sql -r
d:\wip\ds2_wrs_ind_employee_db2.txt
db2cmd /c /w /i DB2 +o -tf ds3_wrs_clr_employee_db2_query.sql -r
d:\wip\ds3_wrs_clr_employee_db2.txt
db2cmd /c /w /i DB2 +o -tf ds4_wrs_client_db2_query.sql -r
d:\wip\ds4_wrs_client_db2.txt
db2cmd /c /w /i DB2 +o -tf ds5_wrs_diary_db2_query.sql -r
d:\wip\ds5_wrs_diary_db2.txt
db2cmd /c /w /i DB2 +o -tf ds6_wrs_dry_history_db2_query.sql -r
d:\wip\ds6_wrs_dry_history_db2.txt
db2cmd /c /w /i DB2 +o -tf ds7_wrs_folder_control_db2_query.sql -r
d:\wip\ds7_wrs_folder_control_db2.txt
--
Thanks,
SnyperSorry, the step does fail. I see it in the appliction log as a failure. I do
not know how to get the .bat to execute properly. Any ideas?
--
Thanks,
Snyper
"snyper" wrote:

> All,
> sql 2000 sp3
> I have a .bat file at d:\wip\queries.bat, the step succeeds, but there is
no
> data in the files that I am creating. Below is the contents of the .bat. I
> have 'd:\queries.bat' in the cmdexec step. I have verified the odbc
> connection, any other ideas would be a great help.
> db2cmd /c /w /i DB2 +o -tf ds1_query.sql -r d:\wip\ds1_query.txt
> db2cmd /c /w /i DB2 +o -tf ds2_wrs_ind_employee_db2_query.sql -r
> d:\wip\ds2_wrs_ind_employee_db2.txt
> db2cmd /c /w /i DB2 +o -tf ds3_wrs_clr_employee_db2_query.sql -r
> d:\wip\ds3_wrs_clr_employee_db2.txt
> db2cmd /c /w /i DB2 +o -tf ds4_wrs_client_db2_query.sql -r
> d:\wip\ds4_wrs_client_db2.txt
> db2cmd /c /w /i DB2 +o -tf ds5_wrs_diary_db2_query.sql -r
> d:\wip\ds5_wrs_diary_db2.txt
> db2cmd /c /w /i DB2 +o -tf ds6_wrs_dry_history_db2_query.sql -r
> d:\wip\ds6_wrs_dry_history_db2.txt
> db2cmd /c /w /i DB2 +o -tf ds7_wrs_folder_control_db2_query.sql -r
> d:\wip\ds7_wrs_folder_control_db2.txt
> --
> Thanks,
> Snyper|||Snyper
Although i know nothing of the detail of what you are trying to do here ...
If running the indiviual commands are being created but not populted then
perhaps it might be worth looking at it being a permissions error in creatin
g
the information or permisiions on population the file.
when you run one of these commands what permissions context is it running
under
under, your id, under the os id or under the applicaion you are running the
commands from.
Are the drive letters in the contect of the user and location you are
running them from ie if runnind this on a remote serverits D: will not be th
e
same as you d:
perhap you need to qualify the files such \\<severname>\<sharename>
Can you break these commands down
a simpler command to say display a directory listing work via this method ie
the cmdexec works but not he commnd you are running...
"snyper" wrote:
[vbcol=seagreen]
> Sorry, the step does fail. I see it in the appliction log as a failure. I
do
> not know how to get the .bat to execute properly. Any ideas?
> --
> Thanks,
> Snyper
>
> "snyper" wrote:
>

ExecSQL Task Truncates Ouput Parameter

I am successfully passing several parameters into a SP using the ExecSQL Task. I have a single parameter that is an OUTPUT parameter in the SP.

I always recieve the first character of the OUTPUT string. I have tried chaning the data type of the parameter mapping [AnsiString, String, etc.] and I have tried changing the data type of the OUTPUT parameter [varchar, char, nvarchar, nchar]

In each case, only the frist character of the output value is returned and subsequently passed to the next SSIS component / task.

Any ideas why this value is truncated?It is a String.

One of the previous replies indicated that there is a max lenght on the variable, but I do not see where to set this length. Any further information on the issue is appreciated.

John|||

jloper wrote:

One of the previous replies indicated that there is a max lenght on the variable, but I do not see where to set this length. Any further information on the issue is appreciated.

John

Ignore that, I was wrong. Sorry!

Note to self: Check out your answers before posting them!

-Jamie