Deleting information in a query

G

guidop12

I have a table that is setup like this
ranking Company Total Revenue
1 ABC 123,456
What I want to do is have a delete query(or something) that just deletes the
contents of the Company and the Total Revenue columns and keep the column
ranking with its information.
The SQL coding is below but that deletes all the rows hence deleting the
ranking information.
DELETE CompanyOneYr.Company, CompanyOneYr.[Total Revenue]
FROM CompanyOneYr;

The ranking column is a permanent set of numbers from 1 to 50
Can someone please advise
 
B

Bob Barrows [MVP]

guidop12 said:
I have a table that is setup like this
ranking Company Total Revenue
1 ABC 123,456
What I want to do is have a delete query(or something) that just
deletes the contents of the Company and the Total Revenue columns and
keep the column ranking with its information.
The SQL coding is below but that deletes all the rows hence deleting
the ranking information.
DELETE CompanyOneYr.Company, CompanyOneYr.[Total Revenue]
FROM CompanyOneYr;

The ranking column is a permanent set of numbers from 1 to 50
Can someone please advise

What you want to do is update the columns:

update CompanyOneYr
set Company = ''.[Total Revenue] = Null
 
M

MGFoster

guidop12 said:
I have a table that is setup like this
ranking Company Total Revenue
1 ABC 123,456
What I want to do is have a delete query(or something) that just deletes the
contents of the Company and the Total Revenue columns and keep the column
ranking with its information.
The SQL coding is below but that deletes all the rows hence deleting the
ranking information.
DELETE CompanyOneYr.Company, CompanyOneYr.[Total Revenue]
FROM CompanyOneYr;

The ranking column is a permanent set of numbers from 1 to 50
Can someone please advise

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The DELETE command deletes the whole row. What you want is the UPDATE
command. Ex:

UPDATE CompanyOneYr
SET Company = NULL,
[Total Revenue] = NULL

This will set the values for columns "Company" and "Total Revenue" to
NULL values (blanks) for the entire table. If you just want to clear
certain rows add the WHERE clause to the command:


UPDATE CompanyOneYr
SET Company = NULL,
[Total Revenue] = NULL
WHERE ranking IN (1,5,7)

This will NULL the columns for rankings 1, 5, and 7.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBSL7wYYechKqOuFEgEQKYawCZAWg3meJJoyQzZU0AMZnVyv0rIQsAnRiX
uu8Afn8uv3lIK9PblSeihjgS
=KMBR
-----END PGP SIGNATURE-----
 
G

guidop12

I tell you, you guys are great
Thank you very much

Bob Barrows said:
guidop12 said:
I have a table that is setup like this
ranking Company Total Revenue
1 ABC 123,456
What I want to do is have a delete query(or something) that just
deletes the contents of the Company and the Total Revenue columns and
keep the column ranking with its information.
The SQL coding is below but that deletes all the rows hence deleting
the ranking information.
DELETE CompanyOneYr.Company, CompanyOneYr.[Total Revenue]
FROM CompanyOneYr;

The ranking column is a permanent set of numbers from 1 to 50
Can someone please advise

What you want to do is update the columns:

update CompanyOneYr
set Company = ''.[Total Revenue] = Null

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top