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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Store Procedure - Get Date
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

wsilage
Yak Posting Veteran

USA
82 Posts

Posted - 03/18/2013 :  08:37:35  Show Profile  Reply with Quote
I need some advice. Below is a store procedure that needs to run twice a day, but the output file cannot have the same records in it as the previous time it would run.

At first they just wanted daily so I added a get date in there, but now they want it twice a day. My getdate seems to keep putting the same claim on both reports and I don't want that.

What can I do to have this pull correctly?


Insert INTO TCN.DBO.TCN_CITY_Savannah (clm_id1, Date, clm_5, clm_65a, clm_clir, clm_rcvd, clm_6a, clm_6b, clm_tchg, clm_nego, clm_sppo, clm_form, clm_att1, clm_att2, clm_att3, clm_att4, clm_att5, clm_chast,
clm_stades, clm_snto, clm_adjto)

SELECT DISTINCT
clm_id1, CONVERT(date, GETDATE())as Date, clm_5, clm_65a, clm_clir, clm_rcvd, clm_6a, clm_6b, clm_tchg, clm_nego, clm_sppo, clm_form, clm_att1, clm_att2, clm_att3, clm_att4, clm_att5, clm_chast,
clm_stades, clm_snto, clm_adjto
FROM impact.dbo.clm
WHERE (clm_clir = 3504) AND (clm_snto = 'TCN') AND (clm_6b >= '01/01/2013') and clm_stades in ('DONE','COMP','BACK')
and Clm_id1 not in (Select clm_id1 from TCN.DBO.TCN_CITY_Savannah)



Select Distinct* from TCN.DBO.TCN_CITY_Savannah
Where
Date = CONVERT(date, GETDATE())

bandi
Flowing Fount of Yak Knowledge

India
2242 Posts

Posted - 03/18/2013 :  08:53:14  Show Profile  Reply with Quote
Is Date column datetime type or date type?
Can you explain your requirement clearly?

--
Chandu
Go to Top of Page

wsilage
Yak Posting Veteran

USA
82 Posts

Posted - 03/18/2013 :  09:41:18  Show Profile  Reply with Quote
datetime
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2242 Posts

Posted - 03/18/2013 :  10:03:26  Show Profile  Reply with Quote
Then insert datetime values into that table twice per day..
While selection you can select one or two records as per your requirement....



--
Chandu
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.14 seconds. Powered By: Snitz Forums 2000