Request For Info - Detecting DB Changes And Batching For E-mail
Feb 7, 2006
I have a .NET app recently ported from 1.1 to 2.0 with a pending feature request. I'd first like to state that I'm not asking anyone for the programmatic answer, unless of course, you'd like to provide it. I'm simply asking the best way to accomplish this task with the tools I have available to me (VS 2005, SQL 2000 and 2005). I do not consider myself a professional .NET or T-SQL programmer but I do have a good understanding of the technologies so that I can find what I need to know once I know I'm going about something the right way.
The application I wrote, from scratch, manages News, Featured Connections, and FAQs for a web site. It was designed in a multi-layer approach where there are:
items -> assigned to categories -> assigned to users
So if user Fred is granted rights to category A, when he authenticates to the app he can Add/Change/Delete any item in category A. Simple enough. But also what Fred can do is see all the other items other users have created and *schedule* any relevant item related to his web page to appear within his own items even tho he has no rights to change that item in the admin interface.
The feature request is a notification service, so that Fred gets an e-mail when someone has added a new item or edited an existing one. I don't want Fred to get an e-mail *every* time an item is created or edited, that would be big bother and would generate lots of e-mails. What I'd like to do is send Fred an e-mail sometime in the middle of the night that informs him of the items added or changed since his last login, so that at his choosing he can go into the admin interface and schedule one or more of those items for his page.
Should I just write a new console app that does this, compile it and schedule the .EXE to run at midnight? Or is there a better way to leverage the new features in SQL 2005 (extended strored procs, triggers) and .NET to do this a better way? Currently, the DB is in SQL 2000 but I have no problems moving it to SQL 2005 if that helps me in some way. Thanks in advance for your comments.
I have some problems with sending Mail over System.Net.Mail ... I have made a C# Class which sends mail, and it works fine. Now I have added this assembly to SQL Server 2005, I made the SQL function and so on.
When I try to run it I get the following message: Msg 50000, Level 16, State 1, Procedure SendMail, Line 114 Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Database Mail only sends SMTP email messages and logs problemsconnecting to the mail server. However, I also need to log bouncedemails (bad address, etc).Are there any clean ways to do this with Database Mail and Exchange?Or will I have to mix Database Mail with SQL Mail to read bounces outof the inbox? Or, have a .NET windows service that talks to theExchange API?
I get this error message when I try to connect to Reporting Services via the Management Studio.
I can see my machine listed in the Server Name > Browse For More > Local Servers dialogue. But no luck,
Ive tried:
Servername: localhost Servername: DED1774 (the machine name) Servername: localhost/reportserver Servername: DED1774/reportserver Servername: http://ded1774/reportserver (from the rsreportserver.config file
<UrlRoot>http://ded1774/reportserver</UrlRoot>)
I've Googled the error message and found postings for solutions, but none of these helped. Can anyone suggest some simple steps I can take to try to find the issue and get the connection working?
I want to be able to see when records have been added to a table. The issue is we have a DTS job scheduled to run every night. The developer who wrote it password protected it and doesn't work here anymore. I want to add a step to this series of DTS jobs and want to run it just prior to his job. Is there a way to see when the records are being added or when this job is being run? Thanks again, you guys are the best.
Is there a TSQL function or value that is assigned to some sort of internal variable when part of a distributed transcation commits? If so, how do I access it? Marc
Does anyone have a good way to detect LOB datatypes for a table or index? I am doing index rebuilds with the ONLINE option and need to work around indexes with LOB datatypes in them...
Is there a preferred method for detecting SQL Server 2005 SP2? I do installation/deployment and during my install script I would prefer to skip the SP2 install if the instance is already upgraded.
I had tried to check HKLMSoftwareMicrosoftMicrosoft SQL ServerInstance NamesSQL to first find out what MSSQL.[n] our instance took.
After that I was attempting to check HKLMSoftwareMicrosoftMicrosoft SQL ServerMSSQL.[n]SetupSP but there have been cases where the key SP did not exist.
I decided I could just install it under the condition that no key existed at all, assuming since the 'SP' key did not exist, the instance was not upgraded. In tests however, after a fresh install of SP2, the key was not there.
I guess the question is further defined as: does installing SP2 place a flag that it exists anywhere else? Is it supposed to write to HKLMSoftwareMicrosoftMicrosoft SQL ServerMSSQL.[n]SetupSP?
Can someone please point me to some code (preferably C#, but C++ or C or VBwill work) that will detect if the (local) instance of SQL Server isrunning on a machine or not? Many thanks!-- Rob
Edit: Newer mind. I tested this query more after writing this, and now it seems to work!I hope it continues to work. In following query, else is never executed.CREATE PROCEDURE Put_into_basket( @Product_code varchar(20))ASBEGIN SET NOCOUNT ON;IF NOT EXISTS(SELECT * FROM dbo.t_shopping_basket WHERE Product_code=@Product_code) BEGIN INSERT dbo.t_shopping_basket (Product_code, Name,Price) SELECT Product_code, Name,Price FROM dbo.t_product WHERE Product_code= @Product_code ENDELSE --this part is never executed BEGIN UPDATE dbo.t_shopping_basket SET Quantity=Quantity+1 WHERE Product_code=@Product_code ENDENDGO The query should test if there is a record or row with Product_code=@Product_code. If there is not, that is the first part, one such row is inserted. Quantity has a default value of 1. Insertion works, one row is inserted. At least sort of. If there is already record, That's later part, Quantity is increased by 1. That too works, if ran separately.But when I test query, it never runs the quantity+1 part.
Is it possible, using VB code, to retain a user on a particular page until the status of a certain field in a database is changed? The scenario I am working on is that a person makes a reservation and has to wait until that reservation has been accepted or rejected by the administration.
Dim dsResv As DataSet dsResv = objResv.DALgetResvStatus(resvId)
While (dsResv.Tables(0).Rows(0).Item("resvStatus") = "pending")
dsResv = objResv.DALgetResvStatus(resvId)
If dsResv.Tables(0).Rows(0).Item("resvStatus") = "denied" Then failure.Visible = True LinkButton1.Visible = True
ElseIf dsResv.Tables(0).Rows(0).Item("resvStatus") = "reserved" Then success.Visible = True LinkButton1.Visible = True End If
End While
This is how I tried to do it, but it doesnt seem to work. Any suggestions?
Can anyone provide me with some SQL that will identify rows from a table where a varchar column named "Notes" contain Carriage Returns?
I know that with report writer SQR I can translate CR's to white space but I do not know of any Sybase function that will allow me to do the same, any ideas on this well would be appreciated.
Table 1 Customers with column CustomerId Table 2 Purchases with columns PurchaseId and CustomerId
I want to select all customers who have made just 1 purchase, what would be the sql for that? I know I can join the tables to get the customers with purchases, but I don't know how to limit it to those with just 1 purchase (and exclude all the other customers).
Folks, I have a SSIS package that works fine 90 % of the time. Every once in a while it gets hung and when I notice that the package has been running for several hours I check the job activity monitor and notice that the package is in executing state for several hours..my question is ...Is there a way I can check for this incidence through a c# app ? Does the package name show up in the process task if so I can poll to see if the process corresponding to the package has been executing for > 30 mins then I can kill it.
I have added a new column to a table, but it is not showing up in the column mapping tab of the lookup editor.
It does show up in the preview.
Without deleting and recreating the component (with all the ensuing broken metadata fixes 'downstream' that this always entails), how can I get it to recognise the change?
In future I will do all LUs as a sql statement so at least I can control columns. This again defeats the purpose of the drag and drop environment..... If it were a harry potter character, it would be a dementor
I am using the Konesans Checksum transformation ( http://www.sqlis.com/21.aspx ) to detect changes in my big (many columns, type 2 SCD) dimensional table.
But I am running into collossions
The checksum transformation, sometimes misses a small change in the record, for instance when a certain flag is set or unset. Is there a more robust checksum generator? Of any other suggestions on to solve this?
How do you find out which service pack is installed on SQL Server? We are installing sp5a but we get an error saying 'cfgchar.exe could not execute' and at the end it says ' can not install successfully'. How can I understand If I really installed sp ?
I can't seem to find a step-by-step guide to how to detect orcontinuously monitor for long-running queries that is suitablefor a comparative SQL Server novice. I know that it is possibleto monitor for such with other database products - can anyoneenlighten me as to how this is done with SQL Server? Ideally,I'd like to snapshot running queries (preferably with querytext) at a particular instant via a script, although any helpto show what queries are running at an instant will be muchappreciated. Any ideas?__________________________________________________ ___________Are you Catholic ?http://www.CatholicEmail.com100s of FREE email addresses --->http://www.UltimateEmail.comSend an Online Greeting Card http://www.UltimateEcards.com
When trying to install SQL 2005, the installation halts at "Detecting Installed IIS". From a previous forum discussion I tried disabling Norton Anti-Virus and Firewall, but the install still does not get past this point.
I know how to detect & delete dups/or >dups in test with a select clause, this works fine in a small table, but if the table has a million rows say, it sounds like a proc would be faster: my question is: How do I display those rows in a proc for detecting what the problem is. The print stmt. doesn't seem to work and I wondered if I had to go through the process of building an output stream. The proc creates okay but I'm stuck after that part.
thx
Kat -- very rough code below
SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO create proc dupcount @count int as set nocount on select categoryID, CategoryName, Count(*) As Dups from Categories group by Categoryid, CategoryName having count(*) >1
I've a table with more columns and 1 identifier. I need to write this table when a modified row is detecting respect to the columns not to the identifier.
So I've created a temporary table to put the potential rows to write on the real table, but I want to detect the modified rows. I've thought to use the checksum function, but I don't know how to use it and if it could be useful in this scenario.
Moreover, in the temporary table I've collected daily the rows to write: the first day a row could have a value respect to his columns, the next day a different value and the next one the same value respect to the first day.
I am installing SQL2005 Develop Edition, it goes to "Detecting Installed IIS" screen and stop there. No error messages, but not moving forward, kinda stuck. I am using XP Professional Service Pack 2, I tried uninstall IIS, got the same result. If anyone knows how to solve this problem, please advice, thanks a lot!
I figured out a way to execute an Oracle Stored Procedure from an Execute SQL Task by using
Declare Begin SomeStoredProc(?,?,?); End;
with an OLE DB connection using the Oracle Provider for OLE DB.
The parameters are getting passed in and the procedure executes but if for some reason it fails SSIS is painting the task green and keeps processing. I'm guessing that's because the outer Declare/End statement completed sucessfully.
I couldn't get it to work as a function with a return value. :(
Is there another way to execute an Oracle stored procedure that I missed?
Can you call an Oracle stored procedure from a Script Task and then fail it on parameter value?
I'm attempting to find a reliable way to determine the file system folder in which the current package is located. (Please note that for this purpose I have no need to support SQL Server deployment, so the fact that there is no current folder in that context is not in scope for this post. )
Anyway, I've added the following code to a Script task in one of my packages:
Code BlockMsgBox(Environment.CurrentDirectory)
When I run the package from DTEXEC I get this the current working folder from which I executed the DTEXEC command line. When I run the package from DTEXECUI I get "C:Projects2005TFSRootSSISCurrentBranchProject", which is the actual folder where the package is located. When I run the package from within Visual Studio (right click, execute package) I get "C:Projects2005TFSRootDocumentationSSIS" which is what is throwing me off. I can't tell where this path is coming from; it is a valid path on my machine, but why it's showing up as the current folder is the mystery. There's no code there and never has been, although I do check in and check out documentation stored in this folder.
I've looked around online but have had no luck in finding any information aboutreliably determining the location of an executing SSIS package. The best I have found is this thread (http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2202954&SiteID=1) which doesn't address the issue I'm seeing.
In short, I'm looking for a consistently reliable mechanism that will allow an SSIS package to be aware of its location at run time, regardless of the mechanism (DTEXEC, DTEXECUI, BIDS, etc.) through which the package is executed. My hopes aren't all that high, but I figured if I was going to get an answer anywhere it would be here.
I've set up DB mail and sent a test e-mail and that comes through fine.
I set up an Operator with email Name: DWhelpton@k-and-s.com;MWeaver@k-and-s.com
I created a job and set up the notifications to e-mail the operator on failure.
When the job runs and fails, I do not get an e-mail and I get the following exception in the db mail log:
Date 2/2/2007 8:35:00 AM Log Database Mail (Database Mail Log)
Log ID 402 Process ID 3936 Last Modified 2/2/2007 8:35:00 AM Last Modified By NT AUTHORITYSYSTEM
Message 1) Exception Information =================== Exception Type: Microsoft.SqlServer.Management.SqlIMail.Server.Common.BaseException Message: Could not retrieve item from the queue. Data: System.Collections.ListDictionaryInternal TargetSite: Microsoft.SqlServer.Management.SqlIMail.Server.Controller.ICommand CreateSendMailCommand(Microsoft.SqlServer.Management.SqlIMail.Server.DataAccess.DBSession) HelpLink: NULL Source: DatabaseMailEngine
StackTrace Information =================== at Microsoft.SqlServer.Management.SqlIMail.Server.Controller.CommandFactory.CreateSendMailCommand(DBSession dbSession) at Microsoft.SqlServer.Management.SqlIMail.Server.Controller.CommandFactory.CreateCommand(DBSession dbSession) at Microsoft.SqlServer.Management.SqlIMail.Server.Controller.CommandRunner.Run(DBSession db) at Microsoft.SqlServer.Management.SqlIMail.IMailProcess.ThreadCallBack.MailOperation(Object o)