473,387 Members | 1,407 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Stored Proc not working in DTS

9
Hi,

I am trying to execute a stored procedure within a DTS. The sp works fine from query analyser and inserts all rows as it should, but when exec in DTS the insert does not occur and the table remains empty.

The stored procedure is as follows:

CREATE PROCEDURE dbo.sp_load_pr_monthly
AS

declare @dater datetime
set @dater = dbo.usf_BeginMonth(getdate());

insert into pr_monthly
select * from pr
where pr.PROJE_MONTH = @dater
GO

The function used:

--determines first day of preceeding input month

CREATE function dbo.usf_BeginMonth (@indate datetime)
returns datetime
begin

declare
@start datetime,
@temp datetime

select @start= cast(year(dateadd(M, -1, @indate)) as varchar(4)) + '-01-' + cast(month(dateadd(M, -1, @indate)) as varchar(2))
return @start

end

Any suggestions as to why this is would be great!

Thanks. :)
Apr 9 '08 #1
2 1008
deepuv04
227 Expert 100+
Hi,

I am trying to execute a stored procedure within a DTS. The sp works fine from query analyser and inserts all rows as it should, but when exec in DTS the insert does not occur and the table remains empty.

The stored procedure is as follows:

CREATE PROCEDURE dbo.sp_load_pr_monthly
AS

declare @dater datetime
set @dater = dbo.usf_BeginMonth(getdate());

insert into pr_monthly
select * from pr
where pr.PROJE_MONTH = @dater
GO

The function used:

--determines first day of preceeding input month

CREATE function dbo.usf_BeginMonth (@indate datetime)
returns datetime
begin

declare
@start datetime,
@temp datetime

select @start= cast(year(dateadd(M, -1, @indate)) as varchar(4)) + '-01-' + cast(month(dateadd(M, -1, @indate)) as varchar(2))
return @start

end

Any suggestions as to why this is would be great!

Thanks. :)
Hi,
I think the date comparison in the select statement used in the procedure is failed because of no timestamp so try change the procedure as follows and try

Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE dbo.sp_load_pr_monthly
  2. AS
  3.  
  4. declare @dater datetime
  5. set @dater = dbo.usf_BeginMonth(getdate());
  6.  
  7. insert into pr_monthly
  8. select * from pr
  9. where datediff(dd,pr.PROJE_MONTH, @dater) = 0
  10. GO
  11.  
Apr 10 '08 #2
JinxT
9
Hi,

Thanks for the solution, it worked perfectly! :-)
Apr 10 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Rhino | last post by:
I am getting an sqlcode of -927 when I execute SQL within a COBOL stored procedure in DB2 OS/390 Version 6 on OS/390. I have looked at the error message for that condition and tried everything I...
1
by: Eric Land | last post by:
Help! I'm trying to call a parameterized stored proc in ASP.NET in VB. I am creating a command object and creating a parametr list, and assigning a value from a session variable (this is working)...
45
by: John | last post by:
Hi When developing vb.bet winform apps bound to sql server datasource, is it preferable to use SELECTs or stored procedure to read and write data from/to SQL Server? Why? Thanks Regards
6
by: Paul M | last post by:
Hi All, I'm currently writing a z/OS DB2 Stored Proc in C, using an example from the IBM Stored Procedure guide (SG24-7083-00). The database calls to read and update the database work...
0
by: balaji krishna | last post by:
Hi, I need to handle the return set from COBOL stored procedure from my invoking Java program. I do not know, how many rows the stored proc SQL fetches.I have declared the cursor in that proc, but i...
7
by: ashtek | last post by:
Hi, I have a generic function that executes a stored procedure & returns a data table. Code: === public static DataTable ExecuteStoredProcedure(string strProc,SqlParameter paramArray) {...
0
by: pompeyoc | last post by:
I am trying to learn how to use stored procedures written in COBOL so I wrote 2 small programs to test it out: the stored procedure and the the calling program. I have no problems compiling them...
2
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I can successfully insert and update the oracle database by calling a oracles stored proc from my .net code. This oracle stored proc is returning some value. I cannot see that...
1
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I can successfully insert and update the oracle database by calling a oracles stored proc from my .net code. This oracle stored proc is returning some value. I cannot see that...
0
by: mirandacascade | last post by:
Questions toward the bottom of the post. Situation is this: 1) Access 97 2) SQL Server 2000 3) The Access app: a) sets up pass-thru query b) .SQL property of querydef is a string, the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.