i have two tables
1) tbluser 2) userlogin
tbluser consist of
username and email
and userlogin looks like
create table userlogin
(
username varchar(50),
[date] datetime
)
i want to select email from tbluser and validate userlogin(table 2)
i want email of the employees from table 1 which are not in table 2 with selected date range
so i created a procedure
alter proc TMSautomail
@datefrm datetime,
@dateto datetime
as
begin
SELECT
tblUser.Email
from
tblUser
inner join
userlogin
on
tblUser.UserName not in userlogin.username
where userlogin.date between @datefrm and @dateto
end
it is showing me error, when i change the procedure to this
alter proc TMSautomail
@datefrm datetime,
@dateto datetime
as
begin
SELECT
tblUser.Email
from
tblUser
left outer join
userlogin
on
tblUser.UserName = userlogin.username
where userlogin.date between @datefrm and @dateto and userlogin.username is null
end
the procedure returns blank column,
i want to fetch email of table one and validate with username which are not in table 2,
my second table is consist of one entry
it should return all rows of table one