Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...SQL and SQL Ser...SQL and SQL Ser...Deleting Data from two tables with a stored procedureDeleting Data from two tables with a stored procedure
Previous
 
Next
New Post
10/6/2010 2:28 PM
 
Hi,

I'm trying to delete data from two tables called [BizQuotes] and [BizQuotes_QuotedProducts].

All the quoted products are stored in the [BizQuotes_QuotedProducts] table and they are connected to the [BizQuotes] table by foreign key. I want to delete all the quotes in the [BizQuotes_QuotedProducts] table first before deleting the linked quote in the [BizQuotes table]. Here is my code in the 01.00.00 SQLDataprovider file

*************

create procedure {databaseOwner}{objectQualifier}BizQuotes_DeleteQuote

@QuoteId int

as

DELETE FROM {objectQualifier}BizQuotes CROSS JOIN {objectQualifier}BizQuotes_QuotedProducts
WHERE (BizQuotes_QuotedProducts.QuoteId = @QuoteId) AND (BizQuotes.QuoteId = @QuoteId)

this is the first time i've attempted something like this as im not quite SQL Savvy but hopefully im not too far off. What am i missing?
 
New Post
10/6/2010 2:46 PM
 
try this Procedure:

CREATE PROCEDURE {databaseOwner}{objectQualifier}BizQuotes_DeleteQuote
@QuoteId int 
AS

DELETE FROM {databaseOwner}{objectQualifier}BizQuotes_QuotedProducts WHERE QuoteId = @QuoteID
DELETE FROM {databaseOwner}{objectQualifier}BizQuotes WHERE QuoteId = @QuoteID

You may omit the first delete if you implement cascading delete from quotes to qouted products.

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
10/6/2010 7:38 PM
 
Thank you sebastian,

that worked a treat. So simple i should have really tried that rather than trying to be too clever
 
New Post
10/6/2010 7:48 PM
 
In many cases, simplicity is the key to great solutions - but like real keys,most of the time, it is difficult to retrieve ;)

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
Previous
 
Next
HomeHomeDevelopment and...Development and...SQL and SQL Ser...SQL and SQL Ser...Deleting Data from two tables with a stored procedureDeleting Data from two tables with a stored procedure


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out