Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

Query
Can someone help me for a SQL query to delete all the transactions from 2
SQL table?
Here is what I want to do.
"Go thru all the transactions in both table A and B
If table A has a record, delete this record first, then delete the same
record info from B

If table A has no record reference, continue and delete the record in B"

and so on.
Thanks



Report this thread to moderator Post Follow-up to this message
Old Post
MC
03-24-06 01:34 AM


Re: Query
MC (webmaster@ozoptics.com)  writes:
> Can someone help me for a SQL query to delete all the transactions from 2
> SQL table?
> Here is what I want to do.
> "Go thru all the transactions in both table A and B
> If table A has a record, delete this record first, then delete the same
> record info from B
>
> If table A has no record reference, continue and delete the record in B"

DELETE B
DELETE A

And most of all, don't delete row by row, delete all in one statement.




--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

Report this thread to moderator Post Follow-up to this message
Old Post
Erland Sommarskog
03-24-06 01:34 AM


Re: Query
My mistake,
Actually, I wanted to delete the records in both Table A and B, before Oct
4, 2004
MC

"Erland Sommarskog" <esquel@sommarskog.se> wrote in message
 news:Xns979040CD7705
Yazorman@127.0.0.1...
> MC (webmaster@ozoptics.com) writes: 
2 
>
> DELETE B
> DELETE A
>
> And most of all, don't delete row by row, delete all in one statement.
>
>
>
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
>
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/pr...oads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodin...ions/books.mspx



Report this thread to moderator Post Follow-up to this message
Old Post
MC
03-24-06 02:31 PM


Re: Query
DELETE TableA.*, TableA.DateField
FROM TableA WHERE TableA.DateField < 10/4/2004


"MC" <webmaster@ozoptics.com> wrote in message
news:OLN%23fw0TGHA.1868@TK2MSFTNGP09.phx.gbl...
> My mistake,
> Actually, I wanted to delete the records in both Table A and B, before Oct
> 4, 2004
> MC
>
> "Erland Sommarskog" <esquel@sommarskog.se> wrote in message
>  news:Xns979040CD7705
Yazorman@127.0.0.1... 
from
> 2 
same 
B" 
http://www.microsoft.com/technet/pr...oads/books.mspx 
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
JP Bless
03-27-06 06:32 PM


Sponsored Links





Last Thread Next Thread
Post New Thread

MS SQL Server Tools archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 08:30 AM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006