June 2, 2011 at 1:11 pm
Hi All,
I have a script which is executed every night. There are about 10 stored procedures run in sequence and finally it populates one table. This table has Unique Primary Key on one column.
One #temp table is created before this table is populated and it checks for the duplicates. If there are duplicates there then it inserts the duplicate data into another table and then deletes them from the original #temp table. Finally the unique data is inserted into the Destination table.
I would like to get a message or some kind of an alert if there is a duplicate data for a given day and it is inserted into duplicated data table. How do I achieve this? I am using SQL 2000 SP2.
Thanks in advance...
June 2, 2011 at 1:32 pm
With 258 points I would think you would know enough to post more info (and maybe even post a sql 2000 question in the correct forum). This is really vague to say the least. During the process where you insert your duplicates to some other table you will need to add some code to send some sort of message or alert. Do you want to send an email (look at xp_sendmail), do you just want to fill yet another table with alerts? Without some clarity on what you want to do we can speculate all day about what you might want to do.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
June 2, 2011 at 1:37 pm
Thanks for the reply Sean. I will make sure I post in the right forum next time. If you like you can move it. And sorry for position it at the wrong place.
Duplicate table will be truncated before the job begins. So, if there are duplicates and the duplicate table is populated then I would like an email to be sent out. Even one duplicated record will also require an email to be sent.
June 2, 2011 at 1:43 pm
Can't move them. :hehe: No worries, apparently I am in on of "those" moods.
At any rate, just before you delete the table of your duplicates you will need to send your email? Check out xp_sendmail. In 2000 that is probably the most direct way to achieve this. If this is being done in a sql job you could even add a SendEmail step prior to deleting the dupes. Just search SSC and you should find plenty of usage examples.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
June 2, 2011 at 1:54 pm
Thanks again.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply