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
 Transact-SQL (2000)
 cursor !!

Author  Topic 

PatDeV
Posting Yak Master

197 Posts

Posted - 2006-02-15 : 14:16:33
Hi all,

How can i create this event.

IO have user and their status!
for example.

select id,user,status from usertbale

use user from usertable and then send email with the id.


Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-02-15 : 14:51:04
I don't understand. Could you provide a data example?

Tara Kizer
aka tduggan
Go to Top of Page

PatDeV
Posting Yak Master

197 Posts

Posted - 2006-02-15 : 15:05:00
Thhere is no data.

the situation is :

Get the data from proj table (status, and id)
and then get user info and then send email with list of ID

thanks
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-02-15 : 15:11:26
Even if you don't currently have data in your system, please make some up so that we can better understand your problem. What e-mail system are you using?

Tara Kizer
aka tduggan
Go to Top of Page

PatDeV
Posting Yak Master

197 Posts

Posted - 2006-02-15 : 15:35:05
in proj table
id status username
4302 2 test
5582 6 test1
5871 3 test3
2258 4 test4

user table

id username email
2258 test4 test4@test.com
5871 test3 test3@test.com
5582 test1
4302 test
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-02-15 : 15:37:50
So now that we have some sample data, what should we do with it? What e-mail system are you using? CDO, SQL Mail, ...?

Tara Kizer
aka tduggan
Go to Top of Page

PatDeV
Posting Yak Master

197 Posts

Posted - 2006-02-15 : 15:56:58
CDO
Go to Top of Page

PatDeV
Posting Yak Master

197 Posts

Posted - 2006-02-15 : 16:06:42
get the id and email it to users such as send id[s] 4258,5871 to test user!!
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-02-15 : 16:14:20
Your subject says cursor. Are you asking how to avoid a cursor or how to use one? If you want to e-mail to multiple userids, then you'll have to loop, whether it be a cursor or a WHILE loop is up to you.

Tara Kizer
aka tduggan
Go to Top of Page

PatDeV
Posting Yak Master

197 Posts

Posted - 2006-02-15 : 16:46:11
so please how can i create cursor for that!!
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-02-15 : 16:50:23
Here's a simple example:


DECLARE @c1 int, @c2 varchar(50)

DECLARE YourCursor CURSOR FOR
SELECT Column1, Column2
FROM YourTable

OPEN authors_cursor

FETCH NEXT FROM YourCursor
INTO @c1, @c2

WHILE @@FETCH_STATUS = 0
BEGIN
EXEC YourEmailStoredProcedure @c1, @c2
END

CLOSE titles_cursor
DEALLOCATE titles_cursor


Tara Kizer
aka tduggan
Go to Top of Page
   

- Advertisement -