Author: Stephen Russell
Posted: 2011-09-21 at 11:59:38
On Wed, Sep 21, 2011 at 10:20 AM, Ajoy Khaund <akhaund@gmail.com> wrote:
> Thanks.
> I have a transactions table where before doing an entry I check if that
> record exists by empno + date + shiftno. If the seek fails I add the records
> else I overwrite existing records. Maybe in SQL server we have to do it
> slightly differently.
--------------------------------
If you add the records in the check I would do all of that inside of a
SPROC I made one below to start you off.
create proc spCheckEmpWorking
@empno varchar(20)
,@wDate datetime
,@shiftno int
as
declare @wSdate datetime , @wEdate datetime
-- figure your date math here to set the scope of time to the shift
they passed it
select id from myTable
where empno = @empno
and wDate between @wSdate and @wEdate
and shiftno = @shifno
if @@rowcount>0
begin
return 1
end
else
begin
-- Do you wnat to insert now? If so do it here
insert into myTable (ColA, ColB, ColC..) values (@empno, ......)
return 1
end
--
Stephen Russell
Unified Health Services
60 Germantown Court
Suite 220
Cordova, TN 38018
Telephone: 888.510.2667
901.246-0159 cell
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/CAJidMYKoY3gtkPOmAZk4BHoKM0=gVJY=4vhQEAc3Lp6sVittxw@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.