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)
 Connecting to ODBC DB and SQL Mail

Author  Topic 

nickfinity
Yak Posting Veteran

55 Posts

Posted - 2005-10-29 : 17:09:01
Hello,

I have taken on a project where I'm wondering if I'm in a little over my head. Using SQL Mail I need to send out e-mails every hour for orders that have shipped. There are two databases. One is SQL Server and the other is only accessible via ODBC (I'm not even sure what type of database it is yet, but it's not SQL Server). The SQL Server database contains the basic order information and the other database contains the order status.

I have the queries I need, but how do I connect via ODBC to the other database from SQL Server? I know (very) little about SQL Mail. Do I set it up as a job under SQL Server Agent jobs so it will run every hour? Can someone give me a push in the right direction?

Thank you very much for any help, I really appreciate it.

Thanks,
Nick

nickfinity
Yak Posting Veteran

55 Posts

Posted - 2005-11-06 : 08:27:05
I now know that I need to create a linked server to access my other db. I haven't set it up yet due to some issues I can't control, but I am working on the queries I need. Once I get the linked server connected can I join a table in SQL Server and a table in the linked server? I've never really had to write any queries like this before.

I need to loop through all the new entries in what I'll call ParentTable. When I get a new ParentTable record I need to find out if it has a ChildTable1 record. If it does I need to check a value in a column. Depending on that value I'll send out one of two emails. If ChildTable1 doesn't exist I need to check ChildTable2. If ChildTable1 exist I'll send out a different email. The email needs to include information from other tables. How do I concatentate my email together? I don't need cursors, do I?

Thanks for any help, I really appreciate it.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-07 : 01:56:30
>>Once I get the linked server connected can I join a table in SQL Server and a table in the linked server?

Yes Like this

Select T.Columns,L.Columns from yourTable T inner join LinkedServer.Dbo.Table L
on T.col=L.col

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -