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 |
|
OwamAthi
Starting Member
4 Posts |
Posted - 2009-10-11 : 10:27:06
|
| good day people.can you please assist me in sending a message via a stored procedure.example:if a certain condition is reached then send a message to certain people. code of condition.declare @counterset @counter=(select * from NumberofUsers where User_Count = 100)if @counter= 100begin*** this is where i want to send the email to the system administrators.endYour assistance will be highly appreciated. ThanksBongs Zwane |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-10-11 : 12:01:36
|
Your select seems not to make any sense but I think it is only an example...Which SQL Server version? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
OwamAthi
Starting Member
4 Posts |
Posted - 2009-10-12 : 01:39:10
|
| SQL server 2008Bongs Zwane |
 |
|
|
OwamAthi
Starting Member
4 Posts |
Posted - 2009-10-13 : 01:24:35
|
| oh i managed to create the stored proc. thanks for the input. the code is as follows:create PROCEDURE spWriteStringToFile (@String Varchar(max), --8000 in SQL Server 2000@Path VARCHAR(255),@Filename VARCHAR(100)--)ASDECLARE @objFileSystem int ,@objTextStream int, @objErrorObject int, @strErrorMessage Varchar(1000), @Command varchar(1000), @hr int, @fileAndPath varchar(80)set nocount onselect @strErrorMessage='opening the File System Object'EXECUTE @hr = sp_OACreate 'Scripting.FileSystemObject' , @objFileSystem OUTSelect @FileAndPath=@path+'\'+@filenameif @HR=0 Select @objErrorObject=@objFileSystem , @strErrorMessage='Creating file "'+@FileAndPath+'"'if @HR=0 execute @hr = sp_OAMethod @objFileSystem , 'CreateTextFile' , @objTextStream OUT, @FileAndPath,2,Trueif @HR=0 Select @objErrorObject=@objTextStream, @strErrorMessage='writing to the file "'+@FileAndPath+'"'if @HR=0 execute @hr = sp_OAMethod @objTextStream, 'Write', Null, @Stringif @HR=0 Select @objErrorObject=@objTextStream, @strErrorMessage='closing the file "'+@FileAndPath+'"'if @HR=0 execute @hr = sp_OAMethod @objTextStream, 'Close'if @hr<>0 begin Declare @Source varchar(255), @Description Varchar(255), @Helpfile Varchar(255), @HelpID int EXECUTE sp_OAGetErrorInfo @objErrorObject, @source output,@Description output,@Helpfile output,@HelpID output Select @strErrorMessage='Error whilst ' +coalesce(@strErrorMessage,'doing something') +', '+coalesce(@Description,'') raiserror (@strErrorMessage,16,1) endEXECUTE sp_OADestroy @objTextStreamEXECUTE sp_OADestroy @objTextStreamBongs Zwane |
 |
|
|
|
|
|
|
|