Using SqlDependency with SQL 2005

Discussion in 'ASP.NET 2.0' started by Aristotle, Feb 15, 2006.

  1. Hello All,

    A really cool feature of ASP.NET 2.0 in conjuction with a SQL 2005 database is the SqlDependency class to cache data (through SqlCacheDependency). It allows your web application to listen for notifications of changed data from the SQL 2005 server. Whereas with SQL 2000, your web application will have to poll the SQL server on a regular basis.

    Here's an example on how to set up a web application for SqlDependency.

    1. Connect to your database with SQL Management Studio, and run this query to enable Service Broker for your database:
     
  2. Do you support this for SQL Server 2000? I think you have to run something on the server to enable notifications.

    Swirl

    CoH/CoV: Online Badge Tracker
    http://www.cityinfoterminal.com
     
  3. Bruce

    Bruce DiscountASP.NET Staff

    SQL 2000's Cache Dependency is sorta lame.

    The idea for SQLDependency is for the SQL server to notify the application when the data set changes. This is the way it works in SQL 2k5.

    With SQL 2k, this behavior is faked. The application will periodically poll a table in the database to see if the data changes.

    Anyway, the answer to your question is, yes, you can use SQL dependency with SQL 2k. However, you may not get the performance gain you expected unless you upgrade to SQL 2k5.

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  4. I have tried running the ALTER DATABASE statement on my database but it just hangs, saying "Executing query". I waited for over 12 minutes before stopping the query.

    Any ideas?
     
  5. Please send a support ticket. System administrators will have to check your SQL 2005 database.

    Aristotle

    DiscountASP.NET
    www.DiscountASP.NET
     

Share This Page