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 2005 Forums
 Transact-SQL (2005)
 Follow TSQL INSERT with form POST

Author  Topic 

mattboy_slim
Yak Posting Veteran

72 Posts

Posted - 2009-03-02 : 17:37:12
Thanks to yosiasz and Peso I have a SQL agent job that does what I need it to do. However, it is possible for the following script to be followed by a string that does a POST to a web page? I want to send an email following the addition of an alert.

INSERT tb_alerts
(
f_alertname,
f_alertgenerated,
f_machineaffected
)
SELECT 'Machine Not Reporting',
GETDATE(),
l.f_itemGUID
FROM tb_locationsmachines AS x
WHERE l.f_machinelastreported < DATEADD(MINUTE, -15, GETDATE())
AND NOT EXISTS (SELECT * FROM tb_alerts AS a WHERE a.f_machineaffected = l.f_itemGUID)


I have no idea if it is possible to do a form POST from TSQL, so if not, I need to find an alternate method to email a user when an alert is generated.

Essentially, after all is done, I'd like to hit a page like this: http://someurl.com/_functions/email_alerts.asp

Thanks in advance,
Matt

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-03-02 : 17:42:29
You can use Database Mail feature in SQL Server 2005 to send an email. You can even add it to your job by calling the Database Mail stored procedure.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

mattboy_slim
Yak Posting Veteran

72 Posts

Posted - 2009-03-03 : 09:53:31
OK, I've been researching and reading for a few hours on Database Mail. It looks like it is going to be a leap to get to that point, and definitely not something I can do here in a day. I will get there, but it may take me some time, since I'm completely new to T-SQL.

So are you telling me that it isn't possible to post to an ASP page? There may be other benefits of doing this also, such as being able to call any external executable (IPCONFIG, VNC, etc).
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-03 : 10:09:43
another way is to use sent mail task available in ssis.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-03-03 : 11:11:59
I have no idea what a post to an ASP is. I realize it's programming terminology, but I'm a DBA and not a programmer so I'm offering what I know on the backend.

Database Mail is very easy to setup. You just need to point it at an email server.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

mattboy_slim
Yak Posting Veteran

72 Posts

Posted - 2009-03-03 : 11:21:54
Sorry, I understand that wasn't very clear. Can I make the script hit a web page, or visit a URL?

EDIT: Another option is to use the script to launch an application. If I can launch an application, such as cURL, then I can use that to visit the web page.
Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2009-03-03 : 12:14:59
you might have to look into system extended procedures. You can create extended procedures in your favourite programming language and deploy it to your database and do what you want it to do. That is a lot of work so you might be better off going the route of the experts' suggestion in this forum.
Go to Top of Page
   

- Advertisement -