jameslester78 (11/24/2012)
create database exampleGO
USE example
GO
Create table tbl_a (email varchar (20),membershipexpiry date)
insert into tbl_a VALUES
('a@a.com','01-Jan-2012'),('b@a.com','01-Jan-2013')
GO
Create proc proc_a
@email varchar(20)
as
declare @v-2 date =
(select membershipexpiry from tbl_a where email = @email)
if @v-2<GETDATE() select 1 as expired
if @v-2>GETDATE() select 0 as expired
Go
exec proc_a @email = 'a@a.com'
exec proc_a @email = 'b@a.com'
GO
use master
drop database example
Normally, a "1" as a return is considered to be a "Yes" or "True" answer. My recommendation would be to change the name of the returned column from "expired" to "IsActive" just to avoid any confusion down the road.
--Jeff Moden
Change is inevitable... Change for the better is not.