Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Monthly Query

Author  Topic 

DrkMaster
Starting Member

11 Posts

Posted - 2004-05-04 : 19:39:23
DECLARE @Now AS datetime, @Month AS datetime

EXECUTE SET @Now = GetDate()
EXECUTE SET @Month = @Now + 30

SELECT * from Contract
WHERE (EndDate <= @Month AND EndDate > @Now)

I can run the previous code from the SQL Server Query Analyzer without any problems and get the resuls quickly and efficiently.

I have an Access Front End (Yes, I know it is not a great solution but this is just the first phase of the project and the next phase will include using a Visual Basic Front End) that lets the users interact with the SQL Server Database.

I would like to store this code as some sort of query or procedure to be run when a user clicks on a certain button. I tried to create a Procedure or a function or even a view without any success. I know I am doing something wrong and going about this the wrong way. I would like someone's help in modifying this code so it would be able to run as a view or procedure. Thank you.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-05-04 : 19:49:22
CREATE PROC SomeProc
AS

DECLARE @Now datetime
DECLARE @Month datetime

SET @Now = GetDate()
SET @Month = @Now + 30

SELECT * from Contract
WHERE (EndDate <= @Month AND EndDate > @Now)




Tara
Go to Top of Page

DrkMaster
Starting Member

11 Posts

Posted - 2004-05-05 : 16:24:32
Thank you
Go to Top of Page
   

- Advertisement -