nick122211
Technical User
Ok maybe I am doing this completely wrong but I am getting weird results. Basically I have a package that reads 4 fields from one DB (server names) and inserts the name into an exec statement for each row found. The problem is it appears it isn't returning all the rows. It is dropping one or two rows inconsistantly. So basically I am missing one server every time this process runs when the package is scheduled to run. To make matters worse when I manually execute the package I have no problems and all the rows are returned? Anyone seen anything like this before? Below is the code. I also have another process that if I schedule doesn't execute properly however if I execute it manually it runs fine.
Thanks
Nick
Declare @Temp Table(RowId Integer Identity(1,1), ServerName VarChar(100))
Insert Into @Temp(ServerName)
Select Server
From SMTPAlert.dbo.servers
Declare @Max Int
Declare @i Int
Declare @ServerName VarChar(100)
Select @Max = Max(RowId),
@i = 1
From @Temp
While @i <= @Max
Begin
Select @ServerName = ServerName
From @Temp
Where RowId = @i
exec SMTPAlert..sp_send_cdosysmail @ServerName,'MailAlert@XXXXX.com','mgmt-svc@XXXXXX.com',@ServerName, @servername
INSERT INTO SMTPAlert.DBO.sendrecieve
(Subject,sent)
VALUES (@servername, current_timeStamp)
Set @i = @i + 1
End
Thanks
Nick
Declare @Temp Table(RowId Integer Identity(1,1), ServerName VarChar(100))
Insert Into @Temp(ServerName)
Select Server
From SMTPAlert.dbo.servers
Declare @Max Int
Declare @i Int
Declare @ServerName VarChar(100)
Select @Max = Max(RowId),
@i = 1
From @Temp
While @i <= @Max
Begin
Select @ServerName = ServerName
From @Temp
Where RowId = @i
exec SMTPAlert..sp_send_cdosysmail @ServerName,'MailAlert@XXXXX.com','mgmt-svc@XXXXXX.com',@ServerName, @servername
INSERT INTO SMTPAlert.DBO.sendrecieve
(Subject,sent)
VALUES (@servername, current_timeStamp)
Set @i = @i + 1
End