Okay jmurrayhead, here's what I got for Part B. but it gives me an error.
Here's the procedure:
Code:
USE [peebman]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_proc_happyBirthday2]
AS
SET NOCOUNT ON
declare @birth datetime, @email varchar(150)
declare row cursor for
select email, convert(varchar(8), birth, 112) from email where birth = convert(varchar(8), getdate(), 112)
open row
fetch next from row into @birth, @email
while @@fetch_status = 0
begin
fetch next from row into @birth, @email
IF convert(varchar(8), @birth, 112) = convert(varchar(8), getdate(), 112)
Begin
declare @body1 varchar(100)
set @body1 = 'You belong in a zoo!'
EXEC msdb.dbo.sp_send_dbmail
@recipients = @email,
--@BCC = @BCCList,
@subject = 'My Mail Test',
@body = @body1,
@body_format = 'html';
end
else if convert(varchar(8), @birth, 112) <> convert(varchar(8), getdate(), 112)
BEGIN
EXEC msdb.dbo.sysmail_stop_sp
End
end
close row
Deallocate row
return
And here's the error:
conversion failed when converting datetime from character to string
Now I shouldn't get this error because the convert should work.
....Or should I use a Cast for the date, but I thought Cast and Convert are basically the same thing. Any ideas on the error?

Originally Posted by
jmurrayhead
Bookmarks