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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 A request for a code snipet by a neophyte user

Author  Topic 

KarinsDad
Starting Member

17 Posts

Posted - 2001-09-06 : 14:55:47
I need to do some simple tasks in SQL Server, however, I am not familiar with the Transact-Sql language.

I need to create a stored procedure and a trigger to do some fairly simple tasks.

The stored procedure has to do a Select on a list of records in a table. The fields consist of a 16 character Text field and a 1 bit flag.

In a loop, the stored procedure has to call an external C++ executable, passing the contents of the text field, and based on the return code and the corresponding bit flag, potentially update the bit for that record in the table.

If the bit is 1 and the return code is 0 (i.e. application successful), then no update occurs. If the bit is 0 and the return code is not 0, then again no update occurs.

Only if both the bit and return code is 0 or if the bit is 1 and the return code is not 0 will the toggle of the bit be done.

The bit flag is effectively used to determine if the success state of running the executable with the given text input has changed since the last time it ran.


The trigger will occur whenever an update occurs on a record. The trigger will send an Email using xp_sendmail with the text of the 16 character field and the state of the bit flag.


Now, I know this is extremely easy for someone who is familiar with Transact-Sql, but for someone unfamiliar with the language, it is a bit of an effort to figure out all of the syntaxes that must be followed, etc.

Thanks in advance for any code snippet or advice.

   

- Advertisement -