Solved

SQL - set certain records to nothing - not null or zero - as if no data was in the columns for selected rows

Posted on 2006-03-21
11
780 Views
Last Modified: 2010-07-27
HI ,

I am trying to update certain rows of a dbase and set certain columns in the rows to nothing. Someone has entered zeros in these columns and I need to update the table and set the rows back to empty (not null or zero)


have tried "  " and '  '  but getting  syntax errors. What can I use to set the rows back to empty as if there was no data there ?

thanks.
0
Comment
Question by:pabby061203
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 9

Expert Comment

by:paelo
ID: 16249269
UPDATE dbo.yourtable
SET yourfield=NULL
WHERE yourfield=0



-Paul.
0
 
LVL 11

Expert Comment

by:star_trek
ID: 16249757
>>>>>>I need to update the table and set the rows back to empty (not null

"nothing" IS null. So if you want to set tjose rows to nothing 0 can't be used as it is int, " " cannot be used as it is varchar... and it is not "nothing".  SO it shld be null

so the query shld be
update <tablename>
set <column>=null WHERE <column>=0
                         
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16250192
>>What can I use to set the rows back to empty as if there was no data there ?<<
If you do not want to use Null, than try this:

Update YourTableName
Set YourColumnName = ''
Where YourColumnName = '0'
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16250207
Also, the following question is considered abandoned, please attend to it:
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/Q_21709703.html
0
 

Author Comment

by:pabby061203
ID: 16256180
Hi again and thanks.


I have found that it is slightly more complicated now. There are complete rows in this table that have been populated with a zero in each cell. I need to identify where the complete rows of zeros are - there may be other rows that have one or two zeros in them - I don't need to update those rows - it is only where a row is totally populated with zeros -not partially populated.


The column names are  Question1, question2, question3, question4 and question5. Tablename is tblanswers.
any ideas ?

thanks again.




0
 

Author Comment

by:pabby061203
ID: 16256470
Hi ,

I have solved this one myself ,  I used  

update tblanswers
set question1 = ' ' where question1 = 0 and question2 = 0 and question3 = 0 and question4 = 0 and question5 = 0


then I ran the same statement to set question2 = ' ' where question1 = 0 etc etc etc etc

thanks
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16264985
>>I have solved this one myself <<
Great! Now please close the question.
0
 

Author Comment

by:pabby061203
ID: 16267917
HI.

I would like to close this question but am not seeing where to do this . Can you point me in the right direction,

thanks
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16276891
>>Can you point me in the right direction<<
Sure.  It is all covered in the EE Help:

What are my choices?
http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/help.jsp#hi67

Accept an Expert's Comment as the Answer http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/help.jsp#hi68
Accept Comments from more than one Expert (a Split) http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/help.jsp#hi69
Request a refund because you answered your own question (Refund/PAQ) http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/help.jsp#hi70 
Request a refund because no one answered your question (Delete) http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/help.jsp#hi71 
Abandon your question and leave the mess for someone else to clean up http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/help.jsp#hi78
0
 

Accepted Solution

by:
GranMod earned 0 total points
ID: 16325099
Closed, 125 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question