If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Deleting information in a query
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 |
#2
|
|||
|
|||
Deleting information in a query
guidop12 wrote:
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. |
#3
|
|||
|
|||
Deleting information in a query
guidop12 wrote:
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/AwUBSL7wYYechKqOuFEgEQKYawCZAWg3meJJoyQzZU0AMZnVyv 0rIQsAnRiX uu8Afn8uv3lIK9PblSeihjgS =KMBR -----END PGP SIGNATURE----- |
#4
|
|||
|
|||
Deleting information in a query
I tell you, you guys are great
Thank you very much "Bob Barrows [MVP]" wrote: guidop12 wrote: 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. |
Thread Tools | |
Display Modes | |
|
|