For Programmers: Free Programming Magazines  


Home > Archive > SQL Server Programming > February 2005 > How can I programatically delete records in tables...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How can I programatically delete records in tables...
trint

2005-02-26, 4:00 pm

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,
trint

David Portas

2005-02-26, 4:00 pm

Here 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
--

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com