Home > Archive > Microsoft SQL Server forum > September 2005 > delete records









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 delete records
Paul

2005-09-20, 1:24 pm

Hello,

I have a database called articles

I want to delete all articles from a subgroup e.g. DVD

If I am in the enterprisemanager what steps do I have to take to do this

thanks in advance

Paul


David Portas

2005-09-20, 1:24 pm

I would do it in Query Analyzser (from EM you can select Tools, SQL
Query Analyzer)

Something like this:

BEGIN TRAN

DELETE
FROM articles
WHERE subgroup = 'DVD'

SELECT * FROM articles

ROLLBACK TRAN

Once you've verified that it deleted what you expected then change the
ROLLBACK to COMMIT.

Make sure you have a backup.

--
David Portas
SQL Server MVP
--

Paul

2005-09-20, 8:23 pm

Hello David,

thank you for your answer it is exactly what I need

kind regards Paul


"David Portas" < REMOVE_BEFORE_REPLYI
NG_dportas@acm.org> schreef in bericht
news:1127237303.004486.198620@g44g2000cwa.googlegroups.com...
>I would do it in Query Analyzser (from EM you can select Tools, SQL
> Query Analyzer)
>
> Something like this:
>
> BEGIN TRAN
>
> DELETE
> FROM articles
> WHERE subgroup = 'DVD'
>
> SELECT * FROM articles
>
> ROLLBACK TRAN
>
> Once you've verified that it deleted what you expected then change the
> ROLLBACK to COMMIT.
>
> Make sure you have a backup.
>
> --
> David Portas
> SQL Server MVP
> --
>



Paul

2005-09-22, 8:24 pm

Hello David

Actually I want do also a rename command
this means not delete the record however change all subgroups with DVD in
e.g. VHS

kind regards Paul

"David Portas" < REMOVE_BEFORE_REPLYI
NG_dportas@acm.org> schreef in bericht
news:1127237303.004486.198620@g44g2000cwa.googlegroups.com...
>I would do it in Query Analyzser (from EM you can select Tools, SQL
> Query Analyzer)
>
> Something like this:
>
> BEGIN TRAN
>
> DELETE
> FROM articles
> WHERE subgroup = 'DVD'
>
> SELECT * FROM articles
>
> ROLLBACK TRAN
>
> Once you've verified that it deleted what you expected then change the
> ROLLBACK to COMMIT.
>
> Make sure you have a backup.
>
> --
> David Portas
> SQL Server MVP
> --
>



SQL

2005-09-22, 8:24 pm

UPDATE articles
SET subgroup ='VHS'
WHERE subgroup = 'DVD'

http://sqlservercode.blogspot.com/

Sponsored Links





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

Copyright 2008 droptable.com