Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
bkpgamble
Starting Member
30 Posts |
Posted - 2006-10-04 : 08:35:28
|
select count(*) INTO IfMailOrNoMail FROM [LagerTilFlow].[dbo].[drives]where TotalProcentFree < 20if IfMailOrNoMail != 0BEGINI want to dosql that sends mail send mailENDif not delete table with infoproblem is I have a fairly large sql I want to send a mail if its true but I just dont seem able to find one that can do the thing I want anny help would be nice I tried using begin end... but dident work |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-10-04 : 08:44:38
|
[code]IF EXISTS (SELECT 1 FROM [LagerTilFlow].[dbo].[drives] WHERE TotalProcentFree < 20) SEND MAIL[/code]Peter LarssonHelsingborg, Sweden |
 |
|
bkpgamble
Starting Member
30 Posts |
Posted - 2006-10-04 : 08:55:21
|
Thanks for the reply I still cant get it to work tholet me add some more info to the problem :)IF EXISTS (SELECT 1 FROM [LagerTilFlow].[dbo].[drives] WHERE TotalProcentFree < 20)DECLARE @TmpMailBody char(1000) SET @TmpMailBody = 'SELECT * from [LagerTilFlow].[dbo].[drives]' EXEC msdb.dbo.sp_send_dbmail @profile_name = 'xxx', @recipients = 'My mail', @subject = 'Database', @query = @TmpMailBody;Go |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-10-04 : 09:00:33
|
[code]IF EXISTS (SELECT 1 FROM [LagerTilFlow].[dbo].[drives] WHERE TotalProcentFree < 20)BEGINDECLARE @TmpMailBody char(1000) SET @TmpMailBody = 'SELECT * from [LagerTilFlow].[dbo].[drives]' EXEC msdb.dbo.sp_send_dbmail@profile_name = 'xxx',@recipients = 'My mail',@subject = 'Database',@query = @TmpMailBody;END[/code]Peter LarssonHelsingborg, Sweden |
 |
|
bkpgamble
Starting Member
30 Posts |
Posted - 2006-10-04 : 09:05:36
|
That did itThanks Peter Larsson |
 |
|
|
|
|