Home Forums SQL Server 2008 SQL Server 2008 - General how to write a stored procedure to check if the members membership has expired RE: how to write a stored procedure to check if the members membership has expired

  • create database example

    GO

    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