Monday, March 26, 2012

How can I programatically delete records in tables...

Ok,
In my c# app, i have a string with an invoice number: "str = 12345".
Using sqlserver2k:
first of all, i understand the c# requirments for putting a command
string in, but don't know the sql command.
this is what i need:
tblPrintInvoice has one record with this column_invoice_number#.
tblInvoiceDetails has maybe up to 50.
How can I delete str(12345) in both tables most efficiently?
Also, i may need to put a flag in each record instead of deleting
them...like:
column_invoice_flag for all 12345 records gets an "insert?" of (reprint
- don't delete) instead of deleting.
any help is appreciated.
thanks,
trintHere are two examples:
DELETE FROM tblInvoiceDetails
WHERE invoice_number = '12345'
UPDATE tblInvoiceDetails
SET deleted = 'Y'
WHERE invoice_number = '12345'
Lookup the DELETE and UPDATE statements in Books Online for the full
syntax.
David Portas
SQL Server MVP
--

No comments:

Post a Comment