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
 General SQL Server Forums
 New to SQL Server Programming
 Store Procedure - Get Date

Author  Topic 

wsilage
Yak Posting Veteran

82 Posts

Posted - 2013-03-18 : 08:37:35
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
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-03-18 : 08:53:14
Is Date column datetime type or date type?
Can you explain your requirement clearly?

--
Chandu
Go to Top of Page

wsilage
Yak Posting Veteran

82 Posts

Posted - 2013-03-18 : 09:41:18
datetime
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-03-18 : 10:03:26
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
   

- Advertisement -